473,320 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

how to redirect a page using javascript?

nirmalsingh
218 100+
hai all,
i am having 2 pages. login.html and city.html

login.html


Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" >
  3. <head>
  4.     <title>Untitled Page</title>
  5.     <script language="javascript" type="text/javascript">
  6.     function validateuser()
  7.     {
  8.         var user= document.getElementById("Text1").value;
  9.         if (user=="admin")
  10.         {
  11.             window.location="city.html?name="+user;
  12.         }
  13.         else
  14.         {
  15.             alert("Login Failed");
  16.             document.getElementById("Text1").value="";
  17.             document.getElementById("Text1").focus();
  18.         }
  19.     }
  20.  
  21.     </script>
  22. </head>
  23. <body>
  24.     <input id="Text1" type="text" />&nbsp;
  25.     <input id="Button1" type="button" value="LOGIN" onclick="validateuser()"/>
  26.  
  27. </body>
  28. </html>
  29.  
City.html

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2.  
  3. <html xmlns="http://www.w3.org/1999/xhtml" >
  4. <head runat="server">
  5.     <title>CITY Page</title>
  6.     <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
  7.     <link href="Styles/EIMS_blue.css" rel="stylesheet" type="text/css"/>
  8.     <script language="javascript" type="text/javascript">
  9.     function getsession()
  10.     {
  11.         var sessionvalue=document.getElementById("sessiondemo").value;
  12.     }
  13.     getvalues();
  14.     function getvalues()
  15.     {
  16.         document.getElementById("username").value="";
  17.         var parameterArray =unescape(self.location.search).substring(1).split( "&");
  18.         var param=parameterArray[0];
  19.         var param1=new Array();
  20.         param1 = param.split('=');
  21.  
  22.         document.getElementById("username").value=param1[1];
  23.         if(document.getElementById("username").value=="undefined")
  24.         {
  25.         window.location="login.html";
  26.         }
  27.  
  28. }
  29.  
  30.     </script>
  31. </head>
  32. <body>
  33.     <script type="text/javascript" src="Scripts/Loaders_Collection.js"></script>
  34.     <input type="text" id="username" />
  35.     <table style ="width:100%; height:100%;" border="0" class="page_bg">
  36.  
  37.         <tr style ="width: 100%;">
  38.             <td style="width:100%;height:126px">Header Area Sample</td>
  39.         </tr>
  40.         <tr style ="width:100%;">
  41.             <td style="width:100%;">
  42.                 <table style="width:100%; height:100%;" border="0">
  43.                     <tr style ="width: 100%;">
  44.                         <td>Menu Area Sample</td>
  45.                         <td>
  46.  
  47.                         </td>
  48.                     </tr>
  49.                 </table>
  50.             </td>
  51.         </tr>
  52.         <tr style ="width:100%;">
  53.             <td style="width:100%;">Footer Area</td>
  54.         </tr>
  55.     </table>
  56. </body>
  57. </html>
  58.  
My problem is while redirecting page in city.html to login.html(when user name not given) the city.html page is shown for a fraction of second. how can i avoid this.

Thanx in advance
Jun 4 '07 #1
2 44390
acoder
16,027 Expert Mod 8TB
You can redirect ok. To solve your problem, you'll need to check using a server-side language. Using just javascript, you won't be able to avoid this.

In any case, you shouldn't be using javascript for login. That should be done strictly server-side.
Jun 4 '07 #2
omtech
1
I think you only need this javascript redirect generator tool to solve your problem.
May 14 '13 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Eric Osman | last post by:
Let's say I want to filter the contents of a target web page, and present a simpler page on the screen. For example, let's say a target web page is full of links, text, images, forms, etc. and...
4
by: ianv2 | last post by:
Hi Is the following possible using Javascript ? I would like a page to redirect to another page if the page expiry has passed. E.G. If my questionnaireform.html page had an expiry date...
2
by: simon.wilkinson | last post by:
Hi, I am trying to update all Select boxes on a page dynamically using javascript, I simple want to change the selected item in each select box when a tick box is pressed on the page. Each...
1
by: ruchinagaich1 | last post by:
Please tell me, How do i open a hyperlink in parent page using javascript?
7
by: vunet.us | last post by:
Can I get the name of a referral page using JavaScript? Just really wondering...
3
by: akristensen | last post by:
I am new to this site, so be patient if I do not ask the question correctly. Current Target Platform: Browser: MS IE, script language: Javascript (will use VBScript, but JS is preferred), External...
1
by: fastvarun | last post by:
Can anybody help me how to remove url while print out of a page using javascript window.print() plz help me...........................
4
by: sva0008 | last post by:
Hi, How do i redirect page in the javascript function? I am using Response.redirect ("LoadDetail_DS.asp"); but it gives me error : 'Response' is undefined. Thanks
28
by: macca | last post by:
Hi, I'm developing an application that is going to be used in schools as a teaching aid and require the ability to temporarily draw on my (as in pages produced by my application) web page using...
4
Ashwani Sharma
by: Ashwani Sharma | last post by:
is there any way to save a web page using javascript in cross browser
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.