Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Set cookie to break a loop

Posted on 1997-07-24
5
Medium Priority
?
216 Views
Last Modified: 2009-07-29
I have a javascript that resizes the window by opening a new and closing the old behind. This is operated with a button. Another button on the new page de-resizes the window. So far so good, but i don't want the browser to be able to resize it again (since this closes the actual browser window). So... what i want to do is to set a cookie that detects if the browser already has been to the page, and if so force the browser to skip the javascript. I imagine that this is done with a simple if/then... but how?

The whole setup is available at: http://www.gp.se/dagl/frames/resize

nyheter9.html loads right.html which has the resize-javascript which launches nyheter10.html that loads right2.html that contains the de-resize-javascript. I want the loop to end there.
Best,
Algabatz
0
Comment
Question by:algabatz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 3

Expert Comment

by:garik
ID: 1268715
Could you clarify where the loop should end? Is it right.html with resize-javascript you don't want to run a second time?
0
 
LVL 3

Accepted Solution

by:
RM032397 earned 400 total points
ID: 1268716
if you work on a window you should be able to find the window.name

When you say 're-size' I take it that you open a new window and put the page into it.

If the window.name is one you do not want to resize then an 'if' clause based on that will do the trick. No need for cookie.
0
 
LVL 1

Author Comment

by:algabatz
ID: 1268717
Thanks, both of you! Well Garic is correct, i don't wish for the "right.html"- javascript to run a second time. How do i prevent this?
0
 
LVL 3

Expert Comment

by:RM032397
ID: 1268718
Your file opens in a window, the name of which you have no control over.

You re-open it in a sized window, named to your specification.

The closing script will run in _your_ named window and in no other.

Here is a real bit of code from one of my demos. This one opens the smae file in a different frame, and only when there gest data from its counterpart.

function getvalues(){ //alert(self.window.name)
if (self.window.name=="HIDING")
{for (var x=0 ; x<6 ; x++)  // allow for hidden fields!
{window.document.forms[0].elements[x].value=parent.MAIN.document.forms[0].elements[x].value};
parent.MAIN.location="cic.htm"
window.document.forms[0].submit()
}
}

0
 
LVL 1

Author Comment

by:algabatz
ID: 1268719
Thanks, this service is so great! I'll be back...
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

705 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