Create New Window in FireFox

I use NetSuite. Within NetSuite I have JavaScript that opens a new window and populate that new window with data.
I tried to run the script within Firefox and I get this error:
A script on this page may be busy, or it may have stopped responding. You can stop the script now, or you can continue to see if the script will complete.  Stop Script or Continue.

No matter how many times I click continue it never finishes.

Is there a different method to opening a window in FireFox?

Here is the working code I use for IE:
//*****Build the output*************
w=window.open('/core/media/media.nl?id=23584&c=364464&h=39b60dc1f5400e058702&_xt=.htm','mypage');
while (w.document.readyState != "complete")
{}
doc=w.document;
doc.getElementById("divBlurb02").innerText=nlapiGetFieldValue('billaddress');
doc.getElementById("divCode").innerText=GCCodes;
doc.getElementById("divBlurb01").innerHTML=str;
doc.getElementById("divBtnPrint").innerText= "Click Here to Print\nPlease select Letterhead\nPrint 1 Copy";
	doc.getElementById("divCode").innerText=GCCodes;
	doc.getElementById("divBlurb01").innerHTML=str;
	doc.getElementById("divBtnPrint").innerText= "Click Here to Print\nPlease select Letterhead\nPrint 1 Copy";

Open in new window

DashteifelAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Michel PlungjanConnect With a Mentor IT ExpertCommented:
while (w.document.readyState != "complete")
{}

is a completely illegal loop in non-ie browsers

You need to give the browser time to breathe and this will run forever in FF anyway since it does not have a readyState

I use innerHTML because innerText also is not supported by FF
//*****Build the output*************
var w=window.open('/core/media/media.nl?id=23584&c=364464&h=39b60dc1f5400e058702&_xt=.htm','mypage'); //template url
if (document.addEventListener) {
  w.document.addEventListener("DOMContentLoaded", insertData, false);
}
else {
  while (w.document.readyState != "complete") {}
  insertData()
}
function insertData() {
  doc=w.document;
  doc.getElementById("divBlurb02").innerHTML=nlapiGetFieldValue('billaddress');
  doc.getElementById("divCode").innerHTML=GCCodes;
  doc.getElementById("divBlurb01").innerHTML=str;
  doc.getElementById("divBtnPrint").innerHTML= "Click Here to Print<br />Please select Letterhead<br />Print 1 Copy";
} 

Open in new window

0
 
DashteifelAuthor Commented:
I can up the point value if this question is difficult.
0
 
Pawel WitkowskiSenior Javascript DeveloperCommented:
This lines makes it "hangs":

while (w.document.readyState != "complete")
{}

instead I would propose to do this:

w.document.body.onload=function ()
{

w=window.open('/core/media/media.nl?id=23584&c=364464&h=39b60dc1f5400e058702&_xt=.htm','mypage');

doc=w.document;
doc.getElementById("divBlurb02").innerText=nlapiGetFieldValue('billaddress');
doc.getElementById("divCode").innerText=GCCodes;
doc.getElementById("divBlurb01").innerHTML=str;
doc.getElementById("divBtnPrint").innerText= "Click Here to Print\nPlease select Letterhead\nPrint 1 Copy";
        doc.getElementById("divCode").innerText=GCCodes;
        doc.getElementById("divBlurb01").innerHTML=str;
        doc.getElementById("divBtnPrint").innerText= "Click Here to Print\nPlease select Letterhead\nPrint 1 Copy";


}
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
Michel PlungjanIT ExpertCommented:
I think an onload or a setTimeout is needed
0
 
DashteifelAuthor Commented:
I noticed my code above repeats itself? So I will re post it.
//*****Build the output*************
w=window.open('/core/media/media.nl?id=23584&c=364464&h=39b60dc1f5400e058702&_xt=.htm','mypage');
while (w.document.readyState != "complete")
{}
doc=w.document;
doc.getElementById("divBlurb02").innerText=nlapiGetFieldValue('billaddress');
doc.getElementById("divCode").innerText=GCCodes;
doc.getElementById("divBlurb01").innerHTML=str;
doc.getElementById("divBtnPrint").innerText= "Click Here to Print\nPlease select Letterhead\nPrint 1 Copy";

Open in new window

0
 
DashteifelAuthor Commented:
I tried your code wilg32, it looks like this:
      var w;
      var doc;
      w.document.body.onload=function ()
      {
      w=window.open('/core/media/media.nl?id=23584&c=364464&h=39b60dc1f5400e058702&_xt=.htm','mypage');
      doc=w.document;
      doc.getElementById("divBlurb02").innerText=nlapiGetFieldValue('billaddress');
      doc.getElementById("divCode").innerText=GCCodes;
      doc.getElementById("divBlurb01").innerHTML=str ;
      doc.getElementById("divBtnPrint").innerText= "Click Here to Print\nPlease select Letterhead\nPrint 1 Copy";
      }

I get an error in FireFox's Error console:
Error: w has no properties
Source File: https://system.netsuite.com/core/media/media.nl?id=32442&c=364464&h=93a215e8d23c53a8a88f&_xt=.js
Line: 193

that points to the code:       w.document.body.onload=function ()

Here is the code for the HTML template that is opening. If that helps.


<html>
 
<script language="JavaScript">
function changeScreenSize(w,h)
{
  window.resizeTo( w,h )
  onBlur = setTimeout("self.focus()",100);
}
var message = "Hello CommServe!!\n\n";
message += "This page is copyrighted, and all content is protected.";
message += "\n\n";
message += "If you want this changed in anyway\n"; 
message += "you must talk with Ray first.";  
 
function click(e) {
  if (document.all) {
    if (event.button == 2) {
      alert(message);
      return false;
    }
  }
  if (document.layers) {
    if (e.which == 3) {
      alert(message);
      return false;
    }
  }
}
 
if (document.layers) {
  document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;
</script>
<head>
<style>
    .LabelSmallRight {border-style:solid; border-width:0; background-color:transparent; color:black; font-size:10px; text-align:right; vertical-align: middle; padding-left:4; padding-right:4; padding-top:1; padding-bottom:1; font-family: Georgia; font-weight: Normal}
    .LabelMediumLeft {border-style:solid; border-width:0; background-color:transparent; color:black; font-size:15px; text-align:left; vertical-align: middle; padding-left:4; padding-right:4; padding-top:1; padding-bottom:1; font-family: Georgia; font-weight: Normal}
    .LabelMediumRight {border-style:solid; border-width:0; background-color:transparent; color:black; font-size:15px; text-align:right; vertical-align: middle; padding-left:4; padding-right:4; padding-top:1; padding-bottom:1; font-family: Georgia; font-weight: Normal}   
</style>
</head>
<body>
 
<div id="divBlurb02" class="LabelMediumLeft" style="z-index: 100; left: 58px; vertical-align: bottom; width: 319px; position: absolute; top: 147px; height: 75px; text-align: left"></div>
 
<table style="width:650px; height:625px;  position: absolute; top: 231px; left: 55px; border-style:none">
    <tr>
        <td valign=center style="width:98%; height:100%"><div id=divBlurb01  class="LabelMediumLeft" style="width:649px; height:100%;"></td>
 
    </tr>
</table>
 
<div id="divCode" class="LabelSmallRight" style="z-index: 100; left: 163px; vertical-align: bottom; width: 545px; position: absolute; top: 913px; height: 16px; text-align: right"></div>
 
    <button id="divBtnPrint" onclick="this.style.visibility='hidden';window.print();this.style.visibility='visible';" style="z-index: 107; left: 177px; width: 311px; position: absolute; top: 20px; height: 114px" type="button">
</body>
</html>

Open in new window

0
 
Pawel WitkowskiSenior Javascript DeveloperCommented:
Ehm i dont know what you mean by that:

   var w;
      var doc;
      w.document.body.onload=function ()


But you declare element w (but it is still undefined), and you use it like a window object. You need a declaration for w that will get a window that you want to load content with :)
0
 
DashteifelAuthor Commented:
I don't know what you mean. I am new this stuff.

What I need is this, or something like this to run in firefox
w=window.open('/core/media/media.nl?id=23584&c=364464&h=39b60dc1f5400e058702&_xt=.htm','mypage');
while (w.document.readyState != "complete")
{/* Not really Used */}
doc=w.document;


I believe I tried your code properly. I posted it above and gave the error message.

Please forgive me, I feel retarted about this.
0
 
Pawel WitkowskiSenior Javascript DeveloperCommented:
var w=window.open('/core/media/media.nl?id=23584&c=364464&h=39b60dc1f5400e058702&_xt=.htm','mypage');
      var doc;
      w.document.body.onload=function ()
      {
      w=window.open('/core/media/media.nl?id=23584&c=364464&h=39b60dc1f5400e058702&_xt=.htm','mypage');
      doc=w.document;
      doc.getElementById("divBlurb02").innerText=nlapiGetFieldValue('billaddress');
      doc.getElementById("divCode").innerText=GCCodes;
      doc.getElementById("divBlurb01").innerHTML=str ;
      doc.getElementById("divBtnPrint").innerText= "Click Here to Print\nPlease select Letterhead\nPrint 1 Copy";
      }


try that
0
 
DashteifelAuthor Commented:
Line: 189
Char: 7
Error: 'document.body' is null or not an object
code: 0
0
 
Pawel WitkowskiSenior Javascript DeveloperCommented:
try the same with document.onload, make sure that this is a html content element
0
 
DashteifelAuthor Commented:
unfortunealty, I do not know what you mean about the html content element.
I am upping the points now.
0
 
Pawel WitkowskiSenior Javascript DeveloperCommented:
I tried you code at URL you provided but it seems that it is not there, can you publish somehow a page with your currently efforts?
0
 
DashteifelAuthor Commented:
I can not publish the page. It is housed inside an online database.  I have the html above for the template that opens. And the javascript that tries to run.
0
 
Michel PlungjanIT ExpertCommented:
w.onload=function ()
0
 
DashteifelAuthor Commented:
still doesn't work.
0
 
Michel PlungjanIT ExpertCommented:
Can you put any programming into
/core/media/media.nl?id=23584&c=364464&h=39b60dc1f5400e058702&_xt=.htm
0
 
DashteifelAuthor Commented:
This line of code opens this template:
<html>
 
<script language="JavaScript">
function changeScreenSize(w,h)
{
  window.resizeTo( w,h )
  onBlur = setTimeout("self.focus()",100);
}
var message = "Hello CommServe!!\n\n";
message += "This page is copyrighted, and all content is protected.";
message += "\n\n";
message += "If you want this changed in anyway\n";
message += "you must talk with Ray first.";  
 
function click(e) {
  if (document.all) {
    if (event.button == 2) {
      alert(message);
      return false;
    }
  }
  if (document.layers) {
    if (e.which == 3) {
      alert(message);
      return false;
    }
  }
}
 
if (document.layers) {
  document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;
</script>
<head>
<style>
    .LabelSmallRight {border-style:solid; border-width:0; background-color:transparent; color:black; font-size:10px; text-align:right; vertical-align: middle; padding-left:4; padding-right:4; padding-top:1; padding-bottom:1; font-family: Georgia; font-weight: Normal}
    .LabelMediumLeft {border-style:solid; border-width:0; background-color:transparent; color:black; font-size:15px; text-align:left; vertical-align: middle; padding-left:4; padding-right:4; padding-top:1; padding-bottom:1; font-family: Georgia; font-weight: Normal}
    .LabelMediumRight {border-style:solid; border-width:0; background-color:transparent; color:black; font-size:15px; text-align:right; vertical-align: middle; padding-left:4; padding-right:4; padding-top:1; padding-bottom:1; font-family: Georgia; font-weight: Normal}  
</style>
</head>
<body>
 
<div id="divBlurb02" class="LabelMediumLeft" style="z-index: 100; left: 58px; vertical-align: bottom; width: 319px; position: absolute; top: 147px; height: 75px; text-align: left"></div>
 
<table style="width:650px; height:625px;  position: absolute; top: 231px; left: 55px; border-style:none">
    <tr>
        <td valign=center style="width:98%; height:100%"><div id=divBlurb01  class="LabelMediumLeft" style="width:649px; height:100%;"></td>
 
    </tr>
</table>
 
<div id="divCode" class="LabelSmallRight" style="z-index: 100; left: 163px; vertical-align: bottom; width: 545px; position: absolute; top: 913px; height: 16px; text-align: right"></div>
 
    <button id="divBtnPrint" onclick="this.style.visibility='hidden';window.print();this.style.visibility='visible';" style="z-index: 107; left: 177px; width: 311px; position: absolute; top: 20px; height: 114px" type="button">
</body>
</html>
0
 
DashteifelAuthor Commented:
//*****Build the output*************
w=window.open('/core/media/media.nl?id=23584&c=364464&h=39b60dc1f5400e058702&_xt=.htm','mypage'); //template url
while (w.document.readyState != "complete")
{}
doc=w.document;
doc.getElementById("divBlurb02").innerText=nlapiGetFieldValue('billaddress');
doc.getElementById("divCode").innerText=GCCodes;
doc.getElementById("divBlurb01").innerHTML=str;
doc.getElementById("divBtnPrint").innerText= "Click Here to Print\nPlease select Letterhead\nPrint 1 Copy";


The code above opens this template below and passes data to the div tags:


<html>
 <script language="JavaScript">
function changeScreenSize(w,h)
{
  window.resizeTo( w,h )
  onBlur = setTimeout("self.focus()",100);
}
var message = "Hello CommServe!!\n\n";
message += "This page is copyrighted, and all content is protected.";
message += "\n\n";
message += "If you want this changed in anyway\n";
message += "you must talk with Ray first.";  
 
function click(e) {
  if (document.all) {
    if (event.button == 2) {
      alert(message);
      return false;
    }
  }
  if (document.layers) {
    if (e.which == 3) {
      alert(message);
      return false;
    }
  }
}
 
if (document.layers) {
  document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;
</script>
<head>
<style>
    .LabelSmallRight {border-style:solid; border-width:0; background-color:transparent; color:black; font-size:10px; text-align:right; vertical-align: middle; padding-left:4; padding-right:4; padding-top:1; padding-bottom:1; font-family: Georgia; font-weight: Normal}
    .LabelMediumLeft {border-style:solid; border-width:0; background-color:transparent; color:black; font-size:15px; text-align:left; vertical-align: middle; padding-left:4; padding-right:4; padding-top:1; padding-bottom:1; font-family: Georgia; font-weight: Normal}
    .LabelMediumRight {border-style:solid; border-width:0; background-color:transparent; color:black; font-size:15px; text-align:right; vertical-align: middle; padding-left:4; padding-right:4; padding-top:1; padding-bottom:1; font-family: Georgia; font-weight: Normal}  
</style>
</head>
<body>
 
<div id="divBlurb02" class="LabelMediumLeft" style="z-index: 100; left: 58px; vertical-align: bottom; width: 319px; position: absolute; top: 147px; height: 75px; text-align: left"></div>
 
<table style="width:650px; height:625px;  position: absolute; top: 231px; left: 55px; border-style:none">
    <tr>
        <td valign=center style="width:98%; height:100%"><div id=divBlurb01  class="LabelMediumLeft" style="width:649px; height:100%;"></td>
 
    </tr>
</table>
 
<div id="divCode" class="LabelSmallRight" style="z-index: 100; left: 163px; vertical-align: bottom; width: 545px; position: absolute; top: 913px; height: 16px; text-align: right"></div>
 
    <button id="divBtnPrint" onclick="this.style.visibility='hidden';window.print();this.style.visibility='visible';" style="z-index: 107; left: 177px; width: 311px; position: absolute; top: 20px; height: 114px" type="button">
</body>
</html>

It works perfectly in Internet Explorer, but DOES NOT work in FireFox.
I get this in FireFox:

A script on this page may be busy, or it may have stopped responding. You can stop the script now, or you can continue to see if the script will complete.  Stop Script or Continue.

No matter how many times I click continue it never finishes.

Any other Ideas?
0
 
Michel PlungjanIT ExpertCommented:
alternatively (and better I think) is in the template to do this

window.onload=function() {
  document.getElementById("divBlurb02").innerHTML=opener.nlapiGetFieldValue('billaddress');
  document.getElementById("divCode").innerHTML=opener.GCCodes;
  document.getElementById("divBlurb01").innerHTML=opener.str;
  document.getElementById("divBtnPrint").innerHTML= opener.clickMessage;

}

and have

var clickMessage = "Click Here to Print<br />Please select Letterhead<br />Print 1 Copy";

in the main page
0
 
DashteifelAuthor Commented:
**This the code that ended up working, thank you to mplungjan for all your work.



//There is more code above this line that I omitted
//*****Build the output******************************************************************
 
	var w=window.open('/core/media/media.nl?id=23584&c=364464&h=39b60dc1f5400e058702&_xt=.htm','mypage'); //template url
	if (document.addEventListener) {
	  alert("The Thank You Letter \nhas been sent to FireFox");
	  w.document.addEventListener("DOMContentLoaded", insertData(GCCodes, str, w), false);
	}	
	else 
	{
	  while (w.document.readyState != "complete") {}
	  insertData(GCCodes, str, w)
	}
	}//this brace belongs to the opening function
 
function insertData(GCCodes, str, w)
{
  doc=w.document;
//doc.getElementById("divBlurb02").innerHTML=nlapiGetFieldValue('billaddress');
  doc.getElementById("divCode").innerHTML=GCCodes;
  doc.getElementById("divBlurb01").innerHTML=str;
  doc.getElementById("divBtnPrint").innerHTML= "Click Here to Print<br />Please select Letterhead<br />Print 1 Copy";
}

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.