Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help getting this IE script to work in firefox 1

Status
Not open for further replies.

randyQ

IS-IT--Management
Apr 26, 2001
117
0
0
US
Ok bear with me, kind of a long explantion coming. In our company, we used to use IE 6. Our Intranet page that loaded on default contained the following code:

--INDEX.HTML--
Code:
<body>
<script>
<!--
  window.open("agreement.html","agreepage","fullscreen")
  window.opener=self
  window.close()
//-->
</script>
</body>

As you can see, this would open a user agreement page in full screen mode, then close the parent window. The agreement page contained the following code:

--AGREEMENT.HTML--
Code:
<body>
<script language="javascript">
<!--
function agree()  \\if user clicks AGREE button
{
  var agreechoice=confirm("Technology User Agreement Confirmation\n\nBy Clicking on 'OK', you are confirming your agreement to the rules and regulation set forth by this district concerning proper Internet use.")
  if (agreechoice)  \\if user clicked AGREE button, then clicked YES on confirm dialog box
  {
    var macagree = "top=0,left=0,width=740,height=540,menubar,scrollbars,status,toolbar,location,resizable"
    var winagree = "top=0,left=0,width=740,height=540,menubar,scrollbars,status,toolbar,location"
    if (navigator.appVersion.indexOf("Win") > 0)
    {
      window.open("Intranet/index.html","main",winagree)
      window.opener=self
      window.close()
    }
    if (navigator.appVersion.indexOf("Mac") > 0)
    {
      window.open("Intranet/index.html","main",macagree)
      window.opener=self
      window.close()
    }
  }
  else  \\if user clicked AGREE button, then clicked NO on confirm dialog box
  {
    window.opener=self
    window.close()
  }
}

function closebrowser()  \\if user clicked DO NOT AGREE button
{
  window.opener=self
  window.close()
}
//-->
</script>
...
...
...
</body>

As you can see, this page contained our user agreement, along with two buttons. If the user did not agree, the browser would close. If they clicked AGREE, then a confirmation window would pop up and make them confirm their agreement. If they clicked YES, they would continue to our main Intranet page, if they clicked NO, then the browser would close.

Our main Intranet page contained the following script:

--INTRANET/INDEX.HTML--
Code:
<head>
...
...
...
<script>
<!--
function windowchange(){
if (navigator.appVersion.indexOf("Win") > 0) {
	if (navigator.appVersion.indexOf("MSIE")!=-1) {
		window.moveTo(0,0);window.resizeTo(screen.availwidth,screen.availheight)}}}

windowchange()
//-->
</script>
</head>

This script would make sure that the page was properly sized and aligned with the users desktop setting.

All in all, this script worked flawlessly in IE 6 (although some of you are probably screaming because there may be a much simpler way to do this). However, we have just made the transition to Firefox 1.0.1, and this script does not work. When run as is, the INDEX.HTML (the very first page) does not close, leaving a window open at all times. The user can then close the agree page without agreeing to anything, and continue surfing on the parent window. That is bad. I know why this script, as is, does not work in firefox. Window.Close() will only work in firefox if it is executed within the same script that opened the window. Since the window was opened by the user when they double-clicked on the Firefox icon, there is no opening script, so firefox blocks the window.close().

Basically, I need help converting my existing script (or writting new script) so that the following occurs:
1) an agreement page loads with no options to navigate away (no address bar, no tool bar, no bookmarks, no additional windows etc.)
2) The user must confirm their agreement to the policy.
3) no additional windows should be open that the user can potentially use to navigate past the agreement without actually agreeing.
4) once agreed to, the intranet index page needs to load and expand to the user's full screen size.

Thank you for enduring such exhausting blabbering, and thank you even more for your assitance.
 
I do have control over the user's system, and can install anything that may be needed to accomplish this.

Also, I would be willing to give up full screen mode, as long as I can force the end user to agree. This is important because, from what I've been told, the agreement is legally binding when they click on Agree. I don't want them to have any other choice but to click agree. That way, when a user downloads some crazy thing, we can disable their user account and give them a good scolding in front of their peers.

Thanks, by the way, for your quick response.
 
Do you know if a confirm alert will be acceptable?

Basically, the license agreement would be put on the main page, and then a little pop-up message would appear asking whether the user accepts the agreement or not.

If this is ok, then let me know where I can send you the files.
 
A simple confirm alert would work fine. I am using something like that now, but it activates on a onUnload event in the body tag, so it makes them agree no matter what happens (refresh, browser close, etc.). I would appreciate anything that would help, because I am getting complaints from users about having to "agree" when they close their browser.

My e-mail is JGrogan "at" piperschools.com

Thank you so much for working on this with me. I am not that great of a coder, and really appreciate your hard work.
 
randyQ,

I don't know what is blocking the realization of only using two windows rather than like you described one closing the other. The two-window scheme should go like this.

[1] The index.htm once called upon, open the agreement window, leaving itself to stay.
[2] Once the choice is made from agreement window either agree or not agree, corresponding action follows.
[2.1] If agreed, the agreement window close itself. Before it closes itself, it executes a statement making the window.opener (ie the index.htm) load up the screen fitting page or whatever indicating the user is received by the site. (Screen fitting is not necessary now, but if you insist on perfect service...) Something like this:
[tt] window.opener.document.url="[/tt]
[2.2] or if disagreed, the agreement window does the same in closing itself. But, this time before closing itself, it instruct the window.opener (the index.htm) load up a local file saying nice work but dismissing the user from using the resources.
[tt] window.opener.document.url="file:///c:\thankyou.htm"[/tt]

regards - tsuji
 
Tsuji, that would work, but I would like to keep the user from minizing the Agreement window, and working directly on the index.htm. The whole point is to force the user to click I Agree. If they don't, they don't get to use the Internet.
 
Amendment:
Escape "\" with "\\" for local file. (That's just as an example. You can serve it with a page with only a close button for the user to close.)
- tsuji
 
But, the agreement window is "fullscreen" no problem. You can keep this no problem.
[tt]window.open("agreement.html","agreepage","fullscreen")[/tt]
that's the point.
The security feature that you note is important. If you want to break it with whatever plugin rather than bend oneself, you can as well use a vbscript to start the ball rolling. With controlling vbscript, you can make the first window close itself and it has control over all the chromes as well.
- tsuji
 
Ok, Kevin, this is really cool stuff. Your script works really well, in that it forces the original window closed if they don't agree. This is what I've wanted.

Here is the next step. I am having trouble fitting our user agreement into the XML page you supplied. I don't know XML, and our user agreement is paragraphs long (far too long to fit in a text value). I've tried multiple text values, but they scroll off screen. Plus, I can't format the text the way I am accustomed to. I know this basically boils down to my not knowing how to code in XML, but that is a mountain that I don't think I'll be able to conquer within the time frame I've been given to solve this problem.

Thank you again for the extension, and for all of your hard work. You earned that star.
 
Let me see if I can figure out a way to let you insert regular html into there. I don't really know the xml specs myself, either.
 
Ok, found the solution on xulplanet.

Replace this line:
Code:
  <text value="Put your User Ageement message here." style=""/>

with the following code:
Code:
	<!-- Credits to: [URL unfurl="true"]http://xulplanet.com/tutorials/xulqa/q_tmpl_html-iterate-full.html[/URL] -->
	<html xmlns:html="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
		<html:body>
			Put your User Ageement message here.
		</html:body>
	</html>

Note: you will need to add html: to the beginning of each html tag so that it knows that it is html code and not xul code. On the other hand, if you want, I think I can make it so that you won't have to do this... it shouldn't take too long.
Some examples:
<html:p>my paragraph</html:p>
Notice how it is added to both the opening and closing tag.


Additional considerations.
Apart from the rather odd situation mentioned above, there are also some other special considerations. Your html must be well written (no sloppy code).
Your HTML will need to conform to the XML/XHTML standard. Basically this means that you will need the do the following:
1) All tags must be properly nested
Wrong:
<i><b>text</i></b>
Correct:
<i><b>text</b></i>
2) All tags must be closed out.
Wrong:
<p>text
<img scr="myimage.png">
Correct:
<p>text</p>
<img src="myimage.png"/>
3) Your tags and attributes must be in lowercase.
Wrong:
<IMG SRC="CAPITAL.PNG"/>
Correct:
<img src="CAPITAL.PNG"/>
 
Ok, this is getting fun. I have my user agreement in there, but now I have one last question. The lines scroll right off the page. How do I fix it so that the paragraphs will be multi-lined, and adjust with the size of the browser window? I will insert my code below so you can see what I've done.

Code:
<groupbox align="center" orient="vertical">
<vbox>
<!-- Credits to: [URL unfurl="true"]http://xulplanet.com/tutorials/xulqa/q_tmpl_html-iterate-full.html[/URL] -->
    <html xmlns:html="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
        <html:body>
		<html:p>I understand and...blah  blah</html:p>
		<html:br/>

		<html:p><html:b>A.  Acceptable Use</html:b></html:p>
		<html:p>Use of internet must...blah blah</html:p>
		<html:br/>

		<html:p><html:b>B.  Procedures</html:b></html:p>
		<html:p>Student users must...blah blah</html:p>
		<html:br/>

		<html:p><html:b>C.  Encounter of Controversial Material</html:b></html:p>
		<html:p>Users may encounter...blah blah</html:p>
		<html:br/>

		<html:p><html:b>D.  Downloading</html:b></html:p>
		<html:p><html:u>Users may not download or install programs without the permission of the district technology coordinator.</html:u></html:p>
		<html:br/>

		<html:p><html:b>E.  Penalties</html:b></html:p>
		<html:p>Users willfully or intentionally violating these rules, applicable state and/or federal laws will face disciplinary action, and their access may be terminated.</html:p>
        </html:body>
    </html>
</vbox>
</groupbox>
 
IT WORKS!!!!

Here is how.

Open Mozilla, type about:config in the address bar. In the filter, type dom.allow

You will see an option that says dom.allow_scripts_to_close_windows

double-click this option to set it to true. BAM!! It works. Now, keep in mind that this only works when you have control over the user setup, which in may case, I do. Also, the fullscreen option does not work, but with a little javascript, you can fix that.

My thanks to all who replied, especially KevinAr. Because of him, I can now write my own extensions, and I've gotten a taste of XML.

I can't believe how much stuff is in the about.config. Firefox is really a neat browser.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top