Why my window.open(...) is not working in IE 7?
I have a index.开发者_开发知识库html page, which contains a buttonid="my-btn"
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>My INDEX PAGE</title>
</head>
<body>
<br><input type="button" id="my-btn" value="OPEN NEW WINDOW"/>
<script src="js/jquery-1.5.1.js"></script>
<script src="js/my.js"></script>
</body>
</html>
js/my.js handles button click event, when my-btn
button is clicked, a new browser window will be popped up with a new page(test.html)
my.js:
$('#my-btn').click(function(){
window.open('test.html', 'testwindow');
});
The new page(test.html) opened in new browser window:
test.html:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>TEST</title>
</head>
<body>
<div id="my-name"></div>
<script src="js/jquery-1.5.1.js"></script>
<script src="js/test.js"></script>
</body>
</html>
Every thing is working fine in FireFox, but I got problem in IE 7.
In IE 7, when my-btn
is clicked, the new window is not popped up, instead, I got error message "Invalid argument" which is point to my js code window.open('test.html', 'testwindow');
, how to make it working in IE then???
Try window.open('test.html','');
(according to this question/answer ie8 var w= window.open() - "Message: Invalid argument.")
Read this.. The problem lies with you second argument..
精彩评论