Wilbur
02-16-2003, 06:06 PM
I am trying to redirect a page to the same page using javascript. Does anyone know of how I can do this without the browser looping.
|
Click to See Complete Forum and Search --> : Javascript code causing browser to loop. Wilbur 02-16-2003, 06:06 PM I am trying to redirect a page to the same page using javascript. Does anyone know of how I can do this without the browser looping. gil davis 02-16-2003, 06:27 PM There is no way to tell if you have already done the redirect. Therefore, there is no way to stop the redirect. There must be some reason you think you have to do this. Why don't you enlighten us? Wilbur 02-16-2003, 06:33 PM I am using javascript to work out the users screen resolution. I then want to pass this variable to the same page which was initially requested by the user. This is why I want to refresh the users page. I dont want them to click a link as I want this to occur when the page initally loads. ie request page, extract user resolution, redirect page so vAriable becomes available to other languages, in this case PHP. Any help would be appreciated. gil davis 02-16-2003, 08:20 PM Javascript cannot communicate any information back to the server directly. If you have something that could take a FORM METHOD=POST or METHOD=GET, then you could set up a form that could send the desired information back to the server. Javascript could help with that. Also, you could use a cookie. Wilbur 02-16-2003, 08:40 PM I am aware of the different issues. I cannot use a form because I want the application to be as seamless as possible. That is why I dont want to use an ahref or a form. I am using PHP sessions so I have to pass a client side varible ie screen.width to the server and display a page based on this. The way I have my pagers configured allows me to take advantage of this variable within the same page. That is whay I cannot use forms or links. Understand Now! Nevermore 02-17-2003, 04:34 AM You could have the page check to see if the user has a cookie installed on their machine. If not, it redirects them to the correct page, and sets a cookie. If they do, it doesn't redirect them, but deletes the cookie. Need any help scripting that? gil davis 02-17-2003, 07:00 AM Originally posted by Wilbur I am using PHP sessions so I have to pass a client side varible ie screen.width to the server and display a page based on this.Security in browsers will not allow such a thing to take place. You obviously do not understand the issues.The way I have my pagers configured allows me to take advantage of this variable within the same page. That is whay I cannot use forms or links. Understand Now! No, I don't. The browser can be redirected according to it's screen.width to load any page you need using a client-side script. But you cannot send information from the client to the server without user intervention. That would be a huge security violation. And it doesn't matter if you are on an intranet. There is no way for the browser to differentiate internet and intranet. It's still a security issue. khalidali63 02-17-2003, 07:15 AM Well if I understand the problem in this thread correctly ,this hsould do what you are trying to do. cheers Khalid <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-5"></meta> <meta name="Author" content="Khalid Ali"></meta> <title>Untitled</title> <link type="text/css" rel="stylesheet" href="http://68.145.35.86/skills/javascripts/style/js_tutorials_style.css"> <style type="text/css"> </style> <script type="text/javascript"> var post = document.location.search; var sW = window.screen.availWidth; var sH = window.screen.availHeight; alert(post) if(post==null || post==""){ document.location.href = document.location.href+"?screenWidth="+sW+"&screenHeight="+sH; } </script> </head> <body> </body> </html> webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |