Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/73.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 如何在IE/Safari中从URL获取锚?_Javascript_Html_Internet Explorer_Safari - Fatal编程技术网

Javascript 如何在IE/Safari中从URL获取锚?

Javascript 如何在IE/Safari中从URL获取锚?,javascript,html,internet-explorer,safari,Javascript,Html,Internet Explorer,Safari,我有一个网页,使用锚导航菜单类别。基本上,当用户单击一个链接时,它会重定向到当前页面,在那里我使用Javascript解析URL中的锚,以确定要显示的页面。除了IE8(及以下版本)和Safari之外,它在所有浏览器中都能完美工作,因为在这些浏览器中,锚根本不会出现在URL中,因此无法解析 在这些浏览器中是否有某种方式链接到锚 代码如下: HTML 编辑:添加代码您可以使用值与ancher标记的href类似的隐藏字段 <a href="../blah-blah/my-page.html"&g

我有一个网页,使用锚导航菜单类别。基本上,当用户单击一个链接时,它会重定向到当前页面,在那里我使用Javascript解析URL中的锚,以确定要显示的页面。除了IE8(及以下版本)和Safari之外,它在所有浏览器中都能完美工作,因为在这些浏览器中,锚根本不会出现在URL中,因此无法解析

在这些浏览器中是否有某种方式链接到锚

代码如下:

HTML


编辑:添加代码

您可以使用值与ancher标记的href类似的隐藏字段

<a href="../blah-blah/my-page.html">
<input type="hidden" name="link-url" value="="../blah-blah/my-page.html"/>


发布您用来执行此操作的代码,否则我们无法提供太多帮助。谢谢,只是添加了它。可能是重复的
var url = window.location.href;  
var loc = url.substring(url.indexOf("#")+1);
<a href="../blah-blah/my-page.html">
<input type="hidden" name="link-url" value="="../blah-blah/my-page.html"/>