Wrox Programmer Forums
|
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
 
Old November 2nd, 2006, 03:02 PM
Banned
 
Join Date: Jul 2005
Posts: 317
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
 
Old November 2nd, 2006, 03:16 PM
Banned
 
Join Date: Jul 2005
Posts: 317
Thanks: 0
Thanked 0 Times in 0 Posts
Default

...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
 
Old November 6th, 2006, 02:33 AM
Registered User
 
Join Date: Nov 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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






Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript works in IE7 not in FF 2 swifty_programmer Javascript 2 August 31st, 2007 02:07 AM
transparentcy and on anything less then IE7 mark jonas PHP How-To 0 March 9th, 2007 09:03 AM
Hack for IE7 Adam H-W CSS Cascading Style Sheets 4 January 23rd, 2007 10:02 AM
JSB2 and IE7 Appleby JSP Basics 0 January 12th, 2007 08:56 PM
IE7 0.7 Snib HTML Code Clinic 2 July 29th, 2004 09:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.