Redirection and opening a new window in IE7

O

Oliver Wong

I'm trying to have the "submit" button of a form open a new window
which loads a PDF, and also to redirect the window containing the submit
button to a new location. Here's a small HTML file demonstrating my code:

<html>
<body>
<input type="button"
onclick="window.open('http://www.cs.ubc.ca/~lowe/papers/ijcv04.pdf');
window.location = 'http://www.google.ca/';"/>
</body>
</html>

This works in IE6 and Firefox, but it seems to fail in IE7. In IE7,
the redirection to a new page will work, but opening the PDF in a new
window will fail. What can I do to get the script to work in IE6, IE7 and
Firefox?

- Oliver
 
E

Evertjan.

Oliver Wong wrote on 30 apr 2007 in comp.lang.javascript:
I'm trying to have the "submit" button of a form open a new window
which loads a PDF, and also to redirect the window containing the
submit button to a new location. Here's a small HTML file
demonstrating my code:

<html>
<body>
<input type="button"
onclick="window.open('http://www.cs.ubc.ca/~lowe/papers/ijcv04.pdf');
window.location = 'http://www.google.ca/';"/>
</body>
</html>

This works in IE6 and Firefox, but it seems to fail in IE7. In
IE7,
the redirection to a new page will work, but opening the PDF in a new
window will fail. What can I do to get the script to work in IE6, IE7
and Firefox?

It's a timing problem, methinks,
the page with it's javascript is gone before the open has had time
enough.

Try this:

===============================================
<script type='text/javascript'>
function ggl(){
window.open('http://www.cs.ubc.ca/~lowe/papers/ijcv04.pdf');
setTimeout('ggl2()',100)
};
function ggl2(){
location.href = 'http://www.google.ca/';
};
</script>

<input type="button" onclick="ggl();">
===============================================
 
O

Oliver Wong

Evertjan. said:
It's a timing problem, methinks,
the page with it's javascript is gone before the open has had time
enough.

Try this:

===============================================
<script type='text/javascript'>
function ggl(){
window.open('http://www.cs.ubc.ca/~lowe/papers/ijcv04.pdf');
setTimeout('ggl2()',100)
};
function ggl2(){
location.href = 'http://www.google.ca/';
};
</script>

<input type="button" onclick="ggl();">
===============================================

This seems to have fixed it. Thanks.

- Oliver
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top