简体   繁体   English

动态生成的链接在IE中不起作用

[英]Dynamically generated links not working in IE

I have a page that uses jQuery to construct links and anchor tags based on existing HTML elements. 我有一个页面,该页面使用jQuery基于现有HTML元素构造链接和锚标记。 It works in all browsers I tested except IE, where the output for the anchor tag was a little different. 它适用于我测试过的所有浏览器,但IE除外,IE的锚标记输出略有不同。

Other browsers: 其它浏览器:

 <a class="courseshortcut" name="TitleJanuary12-13,2013"></a>

Internet Explorer: IE浏览器:

 <a name="TitleJanuary12-13,2013" class="courseshortcut"/>

The generated links to these anchor tags look like this: 生成的指向这些锚标记的链接如下所示:

 <a href="#TitleJanuary12-13,2013">January 12-13, 2013 - Miami, FL</a>

The following section of code in the document.ready function adds the anchors: document.ready函数中的以下代码部分添加了锚点:

 //adds the anchor tags
$('.courseentry').each(function() {
    var str = $(this).find('.coursetitle').html() + $(this).find('.coursedate').html();     
    $(this).prepend("<a class='courseshortcut' name='" + str.replace(/\s+/g, '') + "'></a>");
});

I can't figure out why this issue is occurring. 我不知道为什么会发生此问题。 Can someone enlighten me? 有人可以启发我吗? A more complete version of the test script can be found here . 您可以在此处找到测试脚本的更完整版本。

There are some invalid HTML in your page.Just open in IE and view in developer tool(F12). 您的页面中有一些无效的HTML。只需在IE中打开并在开发人员工具(F12)中查看即可。 eg <div> is inside <p> find this link for more information 例如<div> is inside <p> 查找此链接以获取更多信息

I think IE needs a file name or url before the hashtag 我认为IE在井号之前需要文件名或网址

href="#TitleJanuary12-13,2013"

but i could stand corrected 但我可以纠正

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM