Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/389.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
了解使用javascript打开的页面_Javascript_Jquery_Html - Fatal编程技术网

了解使用javascript打开的页面

了解使用javascript打开的页面,javascript,jquery,html,Javascript,Jquery,Html,我有一个html页面。我使用了3个带有标记的图像,我正在浏览页面。是否有可能知道在新打开的html页面中单击了哪个图像。是,使用javascript 您可以使用JS+Ajax,然后在数据库中插入一个关于image onclick事件的条目 如果您想了解有关此解决方案的更多信息,请提供更多详细信息/代码。当然,请让图像使用的链接具有查询字符串或哈希标记,如下所示: <a href="YourSite.com/YourPage.htm?Image=1"><img src="imag

我有一个html页面。我使用了3个带有标记的图像,我正在浏览页面。是否有可能知道在新打开的html页面中单击了哪个图像。

是,使用javascript

您可以使用JS+Ajax,然后在数据库中插入一个关于image onclick事件的条目


如果您想了解有关此解决方案的更多信息,请提供更多详细信息/代码。

当然,请让图像使用的链接具有查询字符串或哈希标记,如下所示:

<a href="YourSite.com/YourPage.htm?Image=1"><img src="image.png"></a>

最初从和查询字符串代码

-1,我从不建议任何人这样做。慢,不确定你总是得到正确的推荐形象。很抱歉
function getQuerystring(key, default_)
{
  if (default_==null) default_="";
  key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
  var qs = regex.exec(window.location.href);
  if(qs == null)
    return default_;
  else
    return qs[1];
}
if (getQuerystring("Image")=="1"){ ... }