2010-12-08 153 views
1

如何防止IE更新頁面?我希望它表現得像FF,SF & C.由於它是不應該上傳同一頁面...防止IE刷新頁面 - iframe _top

父頁面:

<!DOCTYPE html> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
</head> 
<body> 
    <p>This is the parent page. I don't want this page to reload in IE when the link in the iframe is clicked, since it break our javascript. I only want the "hash" to change.</p> 
    <iframe src="http://example.com/iframepage.html"></iframe> 
</body> 
</html> 

的iframe頁面:

<!DOCTYPE html> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
</head> 
<body> 
    <p>This is the iframe page. The URL is the same as the parent page + anchorlink. When I klick this link in IE the page refresch and the javascript breaks. In FF, SF & C it doesn’t "refresh" page…</p> 
    <a href="http://www.example.com/test.html#test1" target="_top">test1</a> 
</body> 
</html> 
+0

糟糕。我發佈時的HTML disipeard。 父頁的URL:http://www.example.com/test.html iframe中的鏈接:a href =「http://www.example.com/test.html#test1」target = 「_top」> test1 Hakan 2010-12-08 14:52:38

回答

-1

請嘗試此代碼適用於所有瀏覽器

var src = document.getElementById("mydiv").getAttribute("src"); 

if (navigator.appName == "Microsoft Internet Explorer") // ie iframe reload fix 
    document.getElementById("mydiv").setAttribute("src",""); 

$SQuery(mydiv).setAttribute("src",src); // this will not save it in history ;)