【问题标题】:How to embed an iFrame with a URL with a '#' in it in a simplemodal box?如何在简单模式框中嵌入带有“#”的 URL 的 iFrame?
【发布时间】:2012-07-21 02:07:55
【问题描述】:

我正在尝试做以下事情:

$("#link_id").click(function() {
    $.modal('<div class="framed-view"><iframe src="http://domain.com/stuff#12"/></div>');
            });

使用 jQuery simplemodal 插件。

但是,当我单击该链接时 - 显示的链接是: http://domain.com/stuff

而不是

http://domain.com/stuff#12

有谁知道为什么 iframe 会忽略哈希标签之后的所有内容?

【问题讨论】:

    标签: javascript jquery simplemodal


    【解决方案1】:

    问题是这个 HTML 是在 JavaScript 中,当某些字符与标准 JS 字符冲突时必须正确转义。

    像此用户一样使用\ 转义主题标签。 JavaScript function if url has hash tag and user has just navigated forward or back with browser?

    您可能还需要转义 / 字符。

    【讨论】:

    • 在这种情况下不起作用 - 在这里使用 encodeURI() 也不起作用。
    • 这可能与JS本身无关,与simplemodal插件有关。可以取什么样的数据作为参数?
    • 文档说它可以将 HTML 作为参数。 ericmmartin.com/projects/simplemodal
    • 这个东西怎么下载?作者没有让链接很容易找到。 (我可以谷歌,只是发泄。)
    猜你喜欢
    • 2019-07-17
    • 2010-09-19
    • 2022-07-28
    • 1970-01-01
    • 1970-01-01
    • 2015-01-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多