admin管理员组文章数量:1394526
Problem
I'm using the base tag to resolve relative URLs to a specific point in some dynamically generated .html pages.
This works great until I try to use Window.open in javascript. Firefox resolves everything fine, but IE resolves the URL to the displayed URL.
Is there an IE work around for this?
I'd like to avoid
Combining the URL with the href in the base tag via Javascript/jQuery. (Unless it's bullet proof. Recognizing the difference between non-relative urls and relative ones, handling the existince of '/' or none '/' when bining, etc...).
Even if you have such a solution. A built in one would be preferred (a matter of formatting my relative URLs to make IE happy?, or whatever).
Example
<html>
<head>
<base href="" />
<script type="text/javascript">
showWindowPopupFullScreen = function(URL) {
var pageWidth = screen.availWidth;
var pageHeight = screen.availHeight;
var popup = window.open(URL, 'Window', 'height=' + pageHeight + ',width=' + pageWidth + ',top=0,left=0,resizable');
if (window.focus) {
popup.focus();
}
}
</script>
</head>
<body>
<a href="javascript:showWindowPopupFullScreen('users/402706/brandon-boone')">test</a>
</body>
</html>
Problem
I'm using the base tag to resolve relative URLs to a specific point in some dynamically generated .html pages.
This works great until I try to use Window.open in javascript. Firefox resolves everything fine, but IE resolves the URL to the displayed URL.
Is there an IE work around for this?
I'd like to avoid
Combining the URL with the href in the base tag via Javascript/jQuery. (Unless it's bullet proof. Recognizing the difference between non-relative urls and relative ones, handling the existince of '/' or none '/' when bining, etc...).
Even if you have such a solution. A built in one would be preferred (a matter of formatting my relative URLs to make IE happy?, or whatever).
Example
<html>
<head>
<base href="http://stackoverflow." />
<script type="text/javascript">
showWindowPopupFullScreen = function(URL) {
var pageWidth = screen.availWidth;
var pageHeight = screen.availHeight;
var popup = window.open(URL, 'Window', 'height=' + pageHeight + ',width=' + pageWidth + ',top=0,left=0,resizable');
if (window.focus) {
popup.focus();
}
}
</script>
</head>
<body>
<a href="javascript:showWindowPopupFullScreen('users/402706/brandon-boone')">test</a>
</body>
</html>
Share
Improve this question
edited Oct 6, 2010 at 0:23
Brandon J. Boone
asked Oct 5, 2010 at 20:57
Brandon J. BooneBrandon J. Boone
16.5k4 gold badges76 silver badges102 bronze badges
1 Answer
Reset to default 6No idea whether this will work - it might or might not, depending on IE's internal workings - but you could try whether this gets translated properly:
<a href="users/402706/brandon-boone"
onclick="showWindowPopupFullScreen(this.href)">test</a>
本文标签: javascriptwindowopen fails with relative URLs in IE (When using the base tag)Stack Overflow
版权声明:本文标题:javascript - window.open fails with relative URLs in IE (When using the base tag) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744100737a2590859.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论