Getting some exception in my code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vinaykambalimath
    New Member
    • Oct 2009
    • 1

    Getting some exception in my code

    I am opening a blank window and writing a javascript on the new window to submit a form.

    when I execute a line "newWindow.docu ment.write(neww dtxt2);\n\"(3rd line from last) I get an exception and last two lines do not execute. This problem is seen only in IE 6 with IE 7, It works fine. Below mention is my code.

    Code:
    /* line breaks added by Mod */
    function openWindow(url,name,options) {
           var aToken = "";
            aToken ="2121225434349231132674638921:some";
            if(aToken=="") {
            aToken=document.formEMS.AUTHTOKEN.value; }
           var newWindow = window.open("", name);
            if (!newWindow) return false;
            var newwdtxt = "";
            newwdtxt += "<html><head></head>\n";
            newwdtxt += "<body>\n";
            newwdtxt += "<form name=\"eventForm\" method=\"post\" action="+url+ ">\n";
            newwdtxt += "<input type=\"hidden\" name=\"AUTHTOKEN\"";
           newwdtxt += "value= '";newwdtxt += aToken+"'/>\n";
            newwdtxt += "</form>\n";
            newwdtxt += "<scr";
            var newwdtxt1 = "";
            newwdtxt1 += "ipt type=\"text/javascript\" language=\"javascript\">\n"; 
           newwdtxt1 += "window.onLoad=document.eventForm.submit();\n";
            newwdtxt1 += "</scr";
            var newwdtxt2 = "";
            newwdtxt2 += "ipt>\n";
            newwdtxt2 += "</body></html>\n";
            newWindow.document.write(newwdtxt);
           alert(newwdtxt);
            newWindow.document.write(newwdtxt1);
           alert(newwdtxt1);
            alert(newwdtxt2);
            newWindow.document.write(newwdtxt2);
           alert('wrote newwdtxt2');
            return newWindow; }
    Please help me to figure out what is the problem?
    Last edited by Dormilich; Oct 16 '09, 08:51 AM. Reason: Please use [code] tags when posting code
  • vituko
    New Member
    • Dec 2006
    • 48

    #2
    I think you should group the variables in well formed html blocks, or just use one variable :
    Code:
    document.write ('<scr') ;
    document.write ('ipt>...</scr') ;
    document.write ('ipt>') ;
    to
    Code:
    document.write ('<scr'+'ipt>...</scr'+'ipt>') ;
    I have no IE 6
    Last edited by gits; Oct 22 '09, 02:57 AM. Reason: added code tags

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Avoid document.write( ) and make a page, open that and pass the parameters to it. Since you're posting the form as soon as the page loads, why not do this using a server-side page?

      Comment

      Working...