Solved

Create New Window in FireFox

Posted on 2008-06-13
21
356 Views
Last Modified: 2012-06-27
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

0
Comment
Question by:Dashteifel
  • 11
  • 5
  • 5
21 Comments
 

Author Comment

by:Dashteifel
ID: 21781697
I can up the point value if this question is difficult.
0
 
LVL 18

Expert Comment

by:wilq32
ID: 21784516
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
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 21784733
I think an onload or a setTimeout is needed
0
 

Author Comment

by:Dashteifel
ID: 21795879
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
 

Author Comment

by:Dashteifel
ID: 21795940
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
 
LVL 18

Expert Comment

by:wilq32
ID: 21797556
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
 

Author Comment

by:Dashteifel
ID: 21797626
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
 
LVL 18

Expert Comment

by:wilq32
ID: 21797680
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
 

Author Comment

by:Dashteifel
ID: 21797786
Line: 189
Char: 7
Error: 'document.body' is null or not an object
code: 0
0
 
LVL 18

Expert Comment

by:wilq32
ID: 21797859
try the same with document.onload, make sure that this is a html content element
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:Dashteifel
ID: 21798062
unfortunealty, I do not know what you mean about the html content element.
I am upping the points now.
0
 
LVL 18

Expert Comment

by:wilq32
ID: 21798111
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
 

Author Comment

by:Dashteifel
ID: 21798193
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
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 21800384
w.onload=function ()
0
 

Author Comment

by:Dashteifel
ID: 21814977
still doesn't work.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 21815663
Can you put any programming into
/core/media/media.nl?id=23584&c=364464&h=39b60dc1f5400e058702&_xt=.htm
0
 

Author Comment

by:Dashteifel
ID: 21817160
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
 

Author Comment

by:Dashteifel
ID: 21849026
//*****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
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 250 total points
ID: 21853384
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
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 21853406
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
 

Author Comment

by:Dashteifel
ID: 21860539
**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

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Problem to picture file 3 41
jQuery animation faster 1 18
Adding Extra Information box 4 26
Change properties of a dialog box 1 22
When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now