【发布时间】:2015-04-21 13:18:26
【问题描述】:
我正在处理 jquery 加载,它必须从 index.html 页面导航到 container.html。
index.html 页面 jquery 代码如下所示
$(".tblList a").click(function () {
var aUrl = $(this).attr("href");
var page = aUrl.split("?page=");
localStorage.setItem("pageName", page[1]); }); //click end
在 container.html 页面中,我的 html 和 jquery 代码如下所示:
html:
<div id="containerWrapper" class="row"></div>
js:
$(function () {
var pageName = localStorage.getItem("pageName");
$("#containerWrapper").load(pageName + ".html");
$("#containerWrapper").find('a[href^="http"]').click(function () {
alert("http");
window.open(this.href);
return false;
//$('#containerWrapper').load($(this).attr("href"));
});
$('a[href^="ftp"]').click(function () {
alert("ftp");
$(this).attr("target", "_blank");
}); });
$(window).bind('hashchange', function (e) {
var url = window.location.toString();
var innerPagesLink = url.split("?page=")[0];
var innerPagesLinkUrl = url.split("#")[1];
var result = innerPagesLink + "#" + innerPagesLinkUrl;
var replaceUrl = url.replace("?page=", "#");
//alert(innerPagesLink); return false;
window.location = innerPagesLink;
newHash = window.location.hash.substr(1);
$mainContent.load(newHash);
}); //bind end
解决的是:
- 我已成功将页面从 index.html 超链接加载到 container.html div id。
-
在 container.html(已加载页面)中有许多超链接,其中一些具有以下属性:
a href="someother.html"
a href="http://someother.com"
a href="ftp://someother.com"
我正在成功加载指向 div#containerWrapper 的“a href *.html”超链接。
我无法将 http 和 ftp 外部页面加载到我的 div。
我试图打开指向其他选项卡的 http 或 ftp 链接,但我也失败了。 此处附有两个带有示例小提琴的页面:
(这些小提琴不能在本地 mc 中工作的在线工作)
请尝试帮助我,并为我的英语感到抱歉。
【问题讨论】:
标签: jquery