JavaScript - Help? Can Redirect..
what wrong, it just adds the website to the end of the address bar, and it doesnt redirect???help please
<html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <div> <h1>hello</h1> <form onsubmit="return go();"> <select name="website" id="website"> <option value="http://www.google.com/">google.com</option> <option value="www.yahoo.com">yahoo.com</option> </select> <script type="text/javascript"> function go() { var s = getElementById("website"); window.location = s.options[s.selectedIndex].value; return false; //prevents the form from being submitted to the server. } </script> <input type="submit"> </form> </div> </body> </html> Similar TutorialsHey all im new to the forum as i have just started playing round with javascript but anyway i have this code PHP Code: setTimeout(top.location='profilec.php?id=' + id,4000); and when executed the time delay is not taken into account at all and completly ignored. If i remove the id var from the code and just have PHP Code: setTimeout(top.location='profilec.php?id=',4000); its fine can anyone tell me why this is happening and if there is a solution :-) thanks before hand mike Hi, I'm trying to change a piece of code I found in a scipt: Code: if (errors == null) { jQuery('#requestform') .hide() .html('<div class="thankyou"><h1>Merci</h1><p>Nous reviendrons vers vous.</p></div>') .show(); } Instead of the .html () I would like to redirect to another webpage of my website, in the same window. Anyone can help me? Thanks. Hi, I'm trying to redirect my users to their profile, but can't figure out how to put the function into the link. sethighlightedValue(); is a function that returns the users username. Is there anyway else to do this? Here's what I got: Code: case RETURN: window.location = "profile.php?user='setHighlightedValue();'"; this.setHighlightedValue(); bubble = false; break; i'm a total noob with java and can't seem to figure this out. i want to add a bit on to the current url : this is the code i'm using , it just keeps adding... Code: window.location=(window.location+"?p=62"); am i even doing this right.. any help appreciated.. Hello, I need to improve an existing JavaScript redirect by adding a second redirect based on information contained in the URL. First I will outline the situation, then the specifics: I designed a Realtor website using Joomla 1.5 a few years ago. I will call this SITE-1. The site, SITE-1, displays real estate listing from another site (SITE-2) using iFrames. So the listings from SITE-2 appear to be integrated into the pages of SITE-1. Someone shopping for real estate signs up to be notified of new listings. A new listing comes out and an email is sent to the user with a link to the listing - only the link to the listing is located on SITE-2. So I have been using a JavaScript redirect on SITE-2 that asks the question - "is this in an iFrame" ... if no - redirect to SITE-1 and iframe the results. SITE-1 is ready to receive and parses the new URL: Code: <script language="JavaScript"> <!-- // Start if (window == top) { tops = top.location.href location.replace('http://www.SITE-1.com/index.php?option=com_content&view=article&id=42&Itemid=137&iframe='+tops); } // End --> </script> Now, I have a new problem. I don't have access to SITE-2, I only get to submit a template to them. One of the possible links sent to users from SITE-2 contains a variable in the URL: &id=, followed by a 3 digit number. So the full URL might look like this: http://www.site-2.com/index.php?pg=delacct&id=570 I cannot redirect this to the normal page on SITE-1 because Joomla already uses id=, and it just gets confused and drops a 404 page. Instead I need the code I posted above, to FIRST check for id=. If it exists - go to PAGE-A. If not - then do what the script already does as posted above (we'll call that PAGE-B). Can anyone help? (hopefully I explained that so it can be understood) Thanks, --Kevin Hello, I'm new to Javascript Programming. Therefore be patient with me. I'm looking for a script where if someone goes to www.site1.com this site will automatically go to www.site2.com by simulating a mouse click. I've looked everywhere on the internet for a solution but had no luck. Any assistance will be greatly appreciated. Thanks Velvet. I'm trying to figure out how to use an javascript function to redirect without using <body onload>. Normally I use this: Code: <META HTTP-EQUIV="Refresh" Content="0; URL=ajax.php?page=mypage"> But since I'm using ajax, and only want to redirect tha ajax part, the above can not be used... When I have a hyperlink to go to a page in ajax it looks like this: Code: <a href="#" onclick="load('ajax.php?page=mypage','contentarea');return false;"> Is there anyway that I can have the ajax part set into the META HTTP-EQUIV="Refresh" or is there an other way to do this? Thanks in advance... Hi, I have a form in which i have a dropdown list and a submit button. I want to code so that when users select the value from the dropdown list, it should redirect then to the specified page. For instance i have the value, "car", "House" and "pets" in my dropdown listbox, if a use click on "car" it should redirect them to the car page. I have done the following code, but something seems not to work Code: <script type="text/javascript"> function move(){ if (document.sell.cat.value == 'Cars'){ window.location = 'http://www.yourdomain.com' } </script> and in the submit button am calling the function move() Code: <input type="submit" name="button2" id="button2" value="Search" onclick="move()"/> my form name is sell and the dropdown list menu is cat. Thanks Hi guys, I have this script to print a page, which it does fine. However, after the script runs, the browser redirects to the folder root: Code: <SCRIPT Language="Javascript"> //PRINT PAGE FUNCTION function printit(){ if (window.print) { window.print() ; } else { var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>'; document.body.insertAdjacentHTML('beforeEnd', WebBrowser); WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box WebBrowser1.outerHTML = ""; } } </script> How can I stop this happening? I want remain on the current page! Hello everybody, What I have been trying to incorporate into my site is that if a user has javascript turned off, it redirects them to another page. This is what I have found but doesn't seem to work. Code: <NOSCRIPT> <meta http-equiv=”refresh” content=”0; URL=AlternatePage.cfm”> </NOSCRIPT> When I test it out it shows on the page like this: meta http-equiv=”refresh” content=”0; URL=AlternatePage.cfm” Basically shows the same thing without the tags. It doesn't take any action at all. Any ideas, tips, or advice? I don't have any access to the root directory so SSI is not an option at the moment. (Do plan of hosting it on a dedicated server when I have the money ) I need a weird browser redirect. I need a text box, we will call it variable "A", and a submit button on a form. when the person types in a number such as 51225 into the text box and clicks submit it will redirect them to the page yourdomain.com/51225.php. What is the best way in doing this? Code: <html> <head> <script type="text/JavaScript"> <!-- A=document.form.ID.value function onclick(event) { window.location = http://yourdomain.com/document.write(A).php" } //--> </script> </head> <body> <form name="form"> ID: <input type="text" name="ID" size="6" value=""> <input type="submit"> </form> </body> </html> I know this is not correct but it is a start. I can't figure out how to place the variable into the url. I have data pages in my e-commerce site (from 1999) that are imbedded in a parent page using the object tag. I have started to include a little JS snippet that is intended to redirect to the parent if the embedded pages are loaded separately: Code: <script language="JavaScript" type="text/javascript"> try { if (top == self) {top.location.href='parentpage.htm'; } } catch(er) { } </script> This works fine in Firefox, but in IE 7 and 8 it gets into an infinite loop of reloading the parent page into the object frame. Here is a sample: http://www.greathallminis.com/Ancien...s_anc15_mm.htm (I've left this page with the issue, while I have excluded the script for IE elsewhere.) Is there an alternative and equally simple script for IE, or can I modify this to work for IE? Thanks, Rob Hello everyone, I have a problem in redirecting into multiple pages based on if statement result. I have used 3 redirects, only the first one works "redirect1" when I chose any other option.. it always redirects me to the redirect1 page! Please I need your help experts ! The whole code is attached. Hi Guys... I have a slight problem... I'm trying to do a redirect countdown within an iframe and it keeps putting the new page inside the iframe and not opening a new maximized window/tab outside of the iframe. Here is the code for example just going to yahoo: Code: <HEAD> <SCRIPT LANGUAGE="JavaScript"> var start=new Date(); start=Date.parse(start)/1000; var counts=2; function CountDown(){ var now=new Date(); now=Date.parse(now)/1000; var x=parseInt(counts-(now-start),10); if(document.form1){document.form1.clock.value = x;} if(x>0){ timerID=setTimeout("CountDown()", 100) }else{ location.href="http://www.yahoo.com" } } </script> <SCRIPT LANGUAGE="JavaScript"> <!-- window.setTimeout('CountDown()',100); --> </script> </HEAD> <BODY> <center> <FORM NAME="form1"> You are being redirected in <INPUT TYPE="text" NAME="clock" SIZE="2" VALUE="10"> seconds. </FORM> </center> </Body> Here's the kicker... If I replace yahoo.com with some web sites it works PERFECTLY fine and replaces the page with the new page... why is that? I have this offer iframed on my website and I want it so that when they get to a certain page (i have the specific url), I can redirect it to another site. Is this possible by any chance?
Hello All, I have some javscript running on a page to automatically redirect the user to the SSL secured page (https). The code I have works fine when there is www. in front of the site name, but if you just type the site name without the url the code doesn't work. Any suggestions? Thank so much. Code: <script language="javascript" type="text/javascript" > // This is the hostname that will trigger enforcement of redirection. var enableRedirect = true; // This is the hostname that will trigger enforcement of redirection. var externalHostname = "www.exelonenergy.com"; // This is the reconstructed URL if the current URL contains the externalHostname: var redirectURL = "https://" + externalHostname + window.location.pathname; // If the URL contains the externalHostname specified above, // and the protocol in plain http:, then redirect to the https: equivalent: if (enableRedirect == true) { if (window.location.hostname.indexOf(externalHostname) >= 0) { if (window.location.protocol == "http:") { window.location.href = redirectURL; } } } </script> I was wondering how I could redirect from one div to another div after " x " seconds on the same page.. Is this possible? So like basically: Index page: > Shows div1, after x seconds shows div2 etc.. Hello, I am new on forum and javascript. I have got a query for dynamic geo location javascript. I would like to make a page which redirect to another page based on user REGION. Ex. If user from EMEA then page1.html, if user from APAC then page2.html, if user from Other region then page3.html Hope someone will share their ideas with an example to achive this. Thanks Hi, I want to do a redirect count so that the user can see the count going down. for example, I want them to be able to see the following. You will be redirected in 5 seconds. The user should be able to see the count going down from 5 to 4 to 3 to 2 to 1 and then they are redirected. I can get the page to redirect after 5 seconds but I want the user to be able to see it count down. Thanks in advance for your help Theres several redirects probably required, but if it could be 1 script that I could put one 1 html page, that would be amazing (if it is possible). I need the site to: 1. Upon going to site, determine if it is a mobile browser. If so, send visitors to mobile site automatically. If not then continue to step 2. 2. Verify that users can view Flash. If yes check connection speed: A. Send above 60kbits/sec to flash site B. If less send users to html site. If they cannot view Flash, head to step 3 3. For those users that are left, (they can't view flash, and are not using a phone), send them to the html site. I have bolded the 3 versions of the site I have. Please include all code needed, as Im a noob at Javascript programming (explanations on what the lines do would be nice). Thanks Chris Not having a good day...plz help make it WAY better..... |