kwilliams Posted November 2, 2006 Share Posted November 2, 2006 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. Link to comment Share on other sites More sharing options...
aspnetguy Posted November 2, 2006 Share Posted November 2, 2006 try removing the target attribute Link to comment Share on other sites More sharing options...
kwilliams Posted November 2, 2006 Author Share Posted November 2, 2006 try removing the target attributeThat had no affect. By the way, here's the function that it uses:<!-- 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 --> Link to comment Share on other sites More sharing options...
justsomeguy Posted November 2, 2006 Share Posted November 2, 2006 ...but when I tested this link in IE7, it crashed the app all together.That's funny.One thing I might point out is that you have the link pointing to an href, which opens in a blank window, and the link also calls a javascript function which presumably opens the link in a new window, so I would think the result of clicking that link would open two new windows with the same page. 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(); } } Comment out the last two lines and see if it still crashes. If it does not, uncomment the line that opens the actual window, keep the last line commented out, and see if it crashes then. If not, then it doesn't like the last line for whatever reason. Link to comment Share on other sites More sharing options...
kwilliams Posted November 2, 2006 Author Share Posted November 2, 2006 Comment out the last two lines and see if it still crashes. If it does not, uncomment the line that opens the actual window, keep the last line commented out, and see if it crashes then. If not, then it doesn't like the last line for whatever reason.When I commented out the last two lines or the first of the last two lines, it didn't open up anything.Concerning this function possibly opening up two windows, this is the only setup I've found that can open a URL, and then resize that window within one link. If there's another easier way to do it, I'd be very happy to hear about it and use it.I appreciate your help. Thanks. Link to comment Share on other sites More sharing options...
aspnetguy Posted November 2, 2006 Share Posted November 2, 2006 the return false int he onclick event prevents the href from opening. This only happens if javascript is turned off. Link to comment Share on other sites More sharing options...
justsomeguy Posted November 2, 2006 Share Posted November 2, 2006 When I commented out the last two lines or the first of the last two lines, it didn't open up anything.I'm assuming it also didn't crash, so the problem must be the last line then. Have you run it with only the last line commented out?the return false int he onclick event prevents the href from opening. This only happens if javascript is turned off.Ah so Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now