JavaScript - Redirect If Browser And Browser Version Is Safari 4 Or Newer.
I need a script that will redirect to a specific page is the browser is safari version 4. if the browser is NOT safari 4 I want the browser to stay on the current page.
Similar TutorialsHello, I have a question what is the best way to identify a browser, browser version and OS in javascript. I have try a few scripts but they all fail. This will help me out formating the code for diferent browsers. Thanks i don't know what has changed in last releases of Firefox and Opera but before i used this script to detect browser versions (IE, Opera, FF) and block or redirect depending on version Code: <script language="javascript"> <!-- //Detect IE greater than 1 - we are blocking it completely version=0 if (navigator.appVersion.indexOf("MSIE")!=-1){ temp=navigator.appVersion.split("MSIE") version=parseFloat(temp[1]) } if (version>1) window.location="ie-error.html" //Detect Opera less than 10 (9.80) if (navigator.userAgent.indexOf("Opera")!=-1){ var versionindex=navigator.userAgent.indexOf("Opera")+6 if (parseInt(navigator.userAgent.charAt(versionindex))<9.8) window.location="op-error.html" else (window.location="index2.html") } //Detect Firefox less than 3.6 if (navigator.userAgent.indexOf("Firefox")!=-1){ var versionindex=navigator.userAgent.indexOf("Firefox")+8 if (parseInt(navigator.userAgent.charAt(versionindex))<3.6) window.location="ff-error.html" else (window.location="index2.html") } // --> </script> it worked last with Opera 9.5, FF 3.0 but after that it doesnt work at all Firefox'es version (3.6) doesn't get detected and is redirected to error page same goes with Opera (9.8 which is 10.0-10.5) can anyone tell me why this happens ? or can anyone "fix it" i know many people are against this kind of scripts (blockers and redirecters) but i do it so people who come with older and less compatible browsers with W3C standards to get warned so they don't load deformed page I can't seem to get any scrollbars on my Safari Windows Browser to display. I've tried removing my image height and width parameters but it doesn't make any difference. I'm trying to popup a window and when the image is larger than the window, I want to be able to use the scrollbars to see the image. My javascript code (pretty standard I think): PHP Code: function popup_window(url,w,h) { var width=w; var height=h; var from_top=10; var from_left=10; var toolbar='no'; var location='no'; var directories='no'; var status='no'; var menubar='no'; var scrollbars='yes'; var resizable='yes'; var atts='width='+width+'show,height='+height+',top='+from_top+',screenY='; atts+= from_top+',left='+from_left+',screenX='+from_left+',toolbar='+toolbar; atts+=',location='+location+',directories='+directories+',status='+status; atts+=',menubar='+menubar+',scrollbars='+scrollbars+',resizable='+resizable; window.open(url,'win_name',atts); } My calling PHP code as a link on the thumbnail image to be clicked on to popup the window: PHP Code: <A HREF="https://www.mysite.com/<?php echo $php_photo_filename?>" onClick="return popup_window('https://www.mysite.com/<?php echo $php_photo_filename?>', <?php echo $php_popup_width?>, <?php echo $php_popup_height?>)"><IMG SRC="<?php echo $php_small_photo_filename?>" WIDTH="<?php echo $php_small_width?>" HEIGHT="<?php echo $php_small_height?>" BORDER="1"></A> Thanks for any help... Hello forum! This script is supposed to redirect IE 5 to a page on my site. However, the code is not doing the redirect part. Take a look: Code: /******************************************************************************* OLDIE - or Old IE. A script that finds the version of IE you're using, and redirects if lower than the set parameter. [[ Created by Ryan McLaughlin, www.DaoByDesign.com ]] *******************************************************************************/ var browser = navigator.appName var ver = navigator.appVersion var thestart = parseFloat(ver.indexOf("MSIE"))+1 //This finds the start of the MS version string. var brow_ver = parseFloat(ver.substring(thestart+4,thestart+7)) if ((browser=="Microsoft Internet Explorer") && (brow_ver < 5)) //Change to suite { window.location="../oldie.html"; //URL to redirect to. } I also would like to point out that the code belongs in a .js file. NOT <script type="javascript"......... Hi all, How could I make a web page redirect if the user is browsing in Internet Explorer 9. Thanks in advance. ~Ben Perhaps this wouldn't even be Javascript, but here's my question. Is there a script that would direct Opera users past the front page of a web site (that uses flash) to the home page? For instance, a site I'm building as a favor to a church has a flash intro page that is fine with every browser but Opera. (Opera doesn't respond to Autoplay but places a large "Play" button where the flash is located.) On this particular page, the flash movie ends with an "Enter" instruction and is a hyperlink to the "home" page, so if an Opera user clicks that button, they're still not going to see the flash but are going to arrive at the "home" page. Is there a way to not even present them with the flash page, but to send them straight to the home page? I'd appreciate any assistance. Is there a way to redirect your site to another site if the browser doesn't support HTML 5? So, if you where using an old version of IE or Firefox that didn't support HTML 5 it would redirect them to another page. I have a page up with an iframe that's approximately 300px by 405px. When I load up the site in FF and IE, it frames just fine. However, in Chrome and Opera the iframe is shifted upwards and is off-frame. I've tried looking for a solution to center the iframe correctly. Someone said to make a php code that loads 2 different iframes depending on browser (1 iframe for IE/FF and another frame for OP/CH). I have no knowledge of php coding, so I couldn't get it to work. So now, I think I'm limited to redirecting users based on browser type. If the user is using FF or IE, I'll redirect them to my original page. If they're using some other browser, I'll redirect them to a different page without the iframe. I've tried to set up a redirector, but it has trouble distinguishing between FF and Chrome. It treats them exactly the same. Does anyone have any advice on what to do? I've done tons of searching for what seems to be such a small problem. Someone please enlighten me. Greetings, I am currently using the websites tutorial about browser detection using the navigator. http://www.javascriptkit.com/javatutors/navigator.shtml I am however finding myself unable to detect a pattern in order to learn from. My aim is to use Browser detection to have a CSS file for each browser type, such as Firefox, IE, Opera, Safari and then an overall CSS file if none of the above, to fix numerous flaws. For IE and Firefox using the site's code is all well and good and while I haven't tested it yet I'm wondering how to set up the coding so that it can detect a safari browser. There are lots of slashes and d's and brackets and I do find myself unable to understand their purpose. So if someone can explain how I could do it for Safari I would be very appreciative. thinking about implementing some accordion menus. Want to use the latest code. Is this modern code on this site? also, anyone have a link to any modern code for onmouseover instead of onclick navigation through accordion menus? Hey, new guy here, not sure if this should be under XML, but this was my best guess. Am working with javascript, need to pull the text content from a bunch of places on the page, then I build xml with them, and now i want to have a button that will take user to a page in the browser where all they see is the raw xml tree. Help? hey all is there a code where I can detect if the browser is IE6 or IE7 and send them to another webpage? my current design is not compatible with IE6 or 7 and i want to make a new page that's compatible. thanks! I am attempting to make an page on my website where visitors can set my website as their homepage. I am trying to make my website read which browser my visitors are using and then redirects them to the page for the right browser where I can tell them how they can set my website as their homepage. Basically I need exactly the same thing as THIS. Could you explain to me in plain English how I can realize this. This is what I know have: Code: <table width="759" border="0" align="center" cellpadding="0" cellspacing="0" > <tr align="center"> <td width="378" height="28" align="right">Selecteer jouw browser </td> <td width="16"></td> <td width="365" align="left"><form id="browserSelection" name="browserSelection" action="customizeBrowser" method="GET"><select name="browser" size="1" id="browser" onchange="document.browserSelection.submit();"><option value="ff" selected>Firefox</option><option value="ie">Internet Explorer</option><option value="chrome">Chrome</option><option value="opera">Opera</option><option value="safari">Safari</option></select></form></td> </tr> </table> ________________________________________ Please tell me if I make any English mistakes in my posts. I am trying to write as perfectly possible. Hello, I couldn't find another thread that had this problem but it seems like it would be fairly simple. I am also just now starting to learn JavaScript. But when I enter this code into Notepad++ Code: <HTML> <HEAD> </HEAD> <BODY> <SCRIPT type = "text/javascript"> document.write("Hello World"); </SCRIPT> </BODY> </HTML> Instead of printing out "Hello World" as it should, it simply shows me the code I wrote line for line. I have tried opening in both Chrome and IE and since all other webpages work fine I assume that both browsers have javascript enabled. Thanks in advance I have code that I've been using for awhile now that will automatically log users off my site after a period of time. It works great using a 32 bit browser but not at all with a 64 bit browser. For the life of me I can't figure this out. <script type='text/javascript'> var secondsRemaining = 30; var mhcTimer; function countDown() { secondsRemaining -= 1; if (secondsRemaining <= 0) { secondsRemaining = 0; window.location='login.aspx'; } } function startAutoLogoff() { if (mhcTimer) { return false; } else { mhcTimer = setInterval('countDown();', 1000); } } startAutoLogoff(); </script> Hi, I wrote some javascript for a slideshow. The main webpage contains: Code: <FORM NAME="myform"> <IMG SRC="firstimage.jpg" NAME="mypic"><br> <INPUT TYPE="text" SIZE="180" NAME="mycaption" VALUE="First Caption"> <INPUT TYPE="button" VALUE="Prev" NAME="prevbutton" DISABLED=true ONCLICK="slideshowBack()"> <INPUT TYPE="button" VALUE="Next" NAME="nextbutton" ONCLICK="slideshowUp()"> </FORM> which assigns the image and caption for the first picture, and sets the Prev and Next buttons to disabled and not disabled respectively. So you start with the first image and caption, and an enabled "Next" button. I have global javascript variables: num (init to 1), max (init to 7), img1..7 (new Image ()), img1..7.src (filenames for the images), text1..7 (captions for the images), map1..7 (maps for the images). The function for moving to the next slide is: Code: function slideshowUp() { num=num+1 if (num==max+1) {num=1} document.mypic.src=eval("img"+num+".src") document.getElementById("mypic").useMap=eval("map"+num) document.myform.mycaption.value=eval("text"+num) document.getElementById("prevbutton").disabled=(num==1) document.getElementById("nextbutton").disabled=(num==max) } I developed this in HMTLPad (10.2) and it works perfectly in that program's preview mode. But it won't work in the main browsers! In IE 9 (9.0.33), when you click the Next button, nothing at all happens. Image and caption stay the same, Next stays enabled, Prev stays disabled. Maps don't work. Chrome (38.0.2125.122 m) and Firefox (27.0) behave like each other. The images change, but not the captions or the Prev/Next buttons. Maps don't work. Is this to be expected? If so, how do I work around it? Hi, On www.pizzalita.com, I added a div layer that would ask people for an email address and if you don't like to, you camn click the cross to close that layer. This works just fine in Google Chrome but I today realized that it doesn't work for other browsers, not in IE nor in Firefox. Does anyone have any hints, suggestions and tips how to resolve this to get it working properly in all browsers? Firefox says it can't find the function closediv() - but why not, it is there, I can look at the source and I see it.... any clues would be awesome! Thank you very much, help is appreciated! Ron Hi, i wanted to know whats wrong with this coding as its making the browser crash, firefox 5 $(document).ready(function() { /* open rel=external in new window */ $('a[rel=external]').attr('target', '_blank'); /*Scrolling background clouds */ var offset = 600; var offseta = 1450; function scrollbackground() { // decrease the offset by 1, or if its less than 1 increase it by // the background height minus 1 offset = offset + 1; offseta = offseta + 1; // apply the background position if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) { $('#cloud2').css("background-position", offseta + "px top"); } else { $('#cloud').css("background-position", offset + "px top"); $('#cloud2').css("background-position", offseta + "px top"); } // call self to continue animation setTimeout(function() { scrollbackground(); }, 100 ); } // Start the animation scrollbackground(); }); //end I'm trying to use SmoothGallery 2.1 on my website as a featured box. I tried opening the demos provided with the code in all browsers to make sure it was compatible and it showed fine in them all. I copied the javascript onto my site and I'm able to show the gallery. However in Chrome and Internet Explorer it shows fine, but Firefox the images are spread vertically down my site and the javascript gallery box doesn't show. I don't understand why this is an issue because it shows fine opening the demo pages and the javascript code and css is a straight copy from the folder :S Can anyone help me out? Website I'm having the issue on is www.deewon.com -Thanks I was wondering if there was any way to determine what browser the remote address is using through JavaScript preferably or any other language and if so how to direct them to another page if they're using a specific browser...
|