 |
| Javascript General Javascript discussions. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

November 2nd, 2006, 03:02 PM
|
|
Banned
|
|
Join Date: Jul 2005
Posts: 317
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
IE7 and JavaScript
I have an old page that displays a popup window using JavaScript within an ASP page, like this:
Response.Write("<a href='" + strCurrentQSURL + "&print=true' onclick=""NewWindow(this.href,'name','800','600',' yes');return false;"" target='_blank'>Printer-friendly Version</a>")
...but when I tested this link in IE7, it crashed the app all together. When I removed the reference to onclick=""NewWindow(this.href,'name','800','600',' yes');return false;"", it worked fine. I want to keep the window-resize feature, so is there a way to make this javascript open window code work in IE7? Thanks for any help.
KWilliams
|
|

November 2nd, 2006, 03:16 PM
|
|
Banned
|
|
Join Date: Jul 2005
Posts: 317
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
...by the way, here's the function that goes with it:
Code:
<!-- Begin
if (window != top) top.location.href = location.href;
function NewWindow(mypage, myname, w, h, scroll)
{
var winl = (screen.width - w) / 1.5;
var wint = (screen.height - h) / 1.65;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode;
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !containsElement(filter,keyCode)) {
input.value = input.value.slice(0, len);
input.form[(getIndex(input)+1) % input.form.length].focus();
}
function containsElement(arr, ele) {
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}
function getIndex(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form[i] == input)index = i;
else i++;
return index;
}
return true;
}
// End -->
KWilliams
|
|

November 6th, 2006, 02:33 AM
|
|
Registered User
|
|
Join Date: Nov 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I think you have to escape double-quotes by using the backslash instead of double-double-quotes. I thought that was true for all versions of javascript but I could be mistaken.
IE6 doesn't appear to give you an error but I don't think it works correctly either. IE7 actually gives an error.
David
|
|
 |