SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Aug 2005
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem reloading

    Hey everyone,

    I'm writing a script that opens the current page into a new window
    with a different style sheet for printing, don't ask me why it needs
    to open into a new window, it's a request from powers that be! Anyway
    when I reload the page in IE it's fine but in FF it seems to render
    the html without a style sheet!!?? I think it may be to do with a caching
    problem in FF with new windows but I'm not sure. Heres the code I've
    written:

    var w, d, copy;
    //
    function printPage()
    {
    w = window.open('', '' ,'');
    d = w.document;
    copy = "<html>\n<head>\n<title>"+document.title+"</title>\n";
    copy += "<link id='globalStyleSheet' type='text/css' rel='stylesheet'
    href='css/globalPrint.css' />\n";
    copy += "<link id='docStyleSheet' type='text/css' rel='stylesheet'
    href='"+document.getElementById('docStyleSheet').href+"' />";
    copy += "<script language='javascript' type='text/javascript'
    src='scripts/js/utils.js'></script>\n";
    copy += "\n</head>";
    copy += "\n<body>";
    copy += document.body.innerHTML;
    copy += "\n</body>\n</html>";
    d.write(copy);
    d.close();

    }

    function init()
    {
    document.getElementById('printLink').onclick = function(){
    printPage();
    return false;
    }

    }

    I've been racking my brain for a few days now and have finally come to
    a brick wall for a work around..

    Any help or your thoughts would be much appreciated Smile

    Cheers

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's somewhat hard to debug invisible code. Post a working example that demonstrates your problem. The code you posted does nothing an every browser. I would guess you are having problems with the closing </script> tag in the middle of your string.

    Also, use code tags when you post code.

  3. #3
    SitePoint Member
    Join Date
    Aug 2005
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by 7stud View Post
    It's somewhat hard to debug invisible code. Post a working example that demonstrates your problem. The code you posted does nothing an every browser. I would guess you are having problems with the closing </script> tag in the middle of your string.

    Also, use code tags when you post code.
    Hey I've provided a working example of the file as you requested it can be located here: http://www.doomeddeveloper.com/newWindowTest.html any help would be much appreciated !
    Novus Ordo Seclorum

  4. #4
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you are having css problems, then to troubleshoot you should get ride of all irrelevant code, e.g. the <script> tag.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •