JavaScript - Browser Stylesheet Issue
I have the following script on my page:
<![if !IE]> <div id='logowrapper'> <span class='siteLogo'><img src='logo2.png' align=abstop /></span> <span class='findUs'><img src='fLogo.png' border=0 title='Follow us on Facebook' align=abstop /><span class='topdvr'><img src='top_nav_dvr.png' alt=' - ' /></span><a href='www.twitter.com/' rel="nofollow" target='_blank'><img border=0 title='Follow us on Twitter' src='tLogo.png' align=abstop /></a></span> </div> <![endif]> <!--[if IE]> ***** APPLY SAME DIV SO IE RECOGNIZES SAME WAY AS OTHER BROWSER <![endif]--> And i use the following CSS to style the NOT IE browser above: #logowrapper{ margin:15px auto; padding:0px 22px 0px 75px; width:1049px; } .siteLogo { width:45%; } .findUs { padding: 0px 0px 0px 400px; width:45%; } +++++++++++++++++++++++++++ Now my question is how do I achieve the same effect when the user in Internet Explorer browser, either thru DIV or TABLE style? Thank you Similar TutorialsI'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 Hello all, I've got a cross browser issue with two javascript codes I'm using within a website: http://www.thewursteditions.com Someone just pointed out today that they don't see my gallery (galleria javascript) nor my rollover on the size guide. The site works great on the iphone, firefox, and safari, but not in Internet Explorer. I really have no idea what the issue could be as I don't do this too often but I would greatly appreciate any of your help! Thanks Hi i have a php file that contain below content and it works great on firefox but not in IE8 actually IE8 doesnt reload the div Code: <?php print <<<HERE <script type="text/javascript"> $(document).ready(function() { $("#loader").load("content.php?uname=$uname"); var refreshId = setInterval(function() { $("#loader").load("content.php?uname=$uname"); }, 5000); }); </script> HERE; ?> <div id="loader"></div> also i tried like this and same thing happens Code: <?php print <<<HERE <script type="text/javascript"> setInterval("calldiv()", 5000); function calldiv(){ $("#loader").load("content.php?uname=$uname"); } </script> HERE; ?> <div id="loader"></div> any help would be great Thanks. ok, so i am working on a type of Option Box that is heavily formatted with CSS and animated using JS $fx() The $fx framework works fine on all browsers, and i have only used fairly simple code, and yet my page functions perfectly on Chrome and Safari. but will not work in Firefox or IE (Firefox does nothing, and IE has a couple of css issues and doesnt work either...) http://calumk.com/else/blogpoststuff...ng_Option_Box/ if anyone could help me i would really appreciate it. (obviously view in Chrome or safari to see how it is meant to respond) mediasource.saymikeo.com At the bottom of this page, click the web or video big white box. Then turn your attention to the select boxes. When you select either of the first two choices, another box should pop up next to the select box. That box should populate with other choices. 1. My problem is the secondary box does not populate with the correct data. 2. When you select option 3 or 4 the box should disappear. This works in Firefox. This is done through a JSON call in Mootools. If you can figure this out I will think you are totally awesome. First for going through my messy code and second for being able fix it. Your assistance is greatly appreciated. This is the base function that calls view_category() which calls add_select_box(); Code: function build_page(url, id){ $('ajax_box').set('html', ''); dbug.log('Obj URL: ', id, url); // Get the requested view var view = new Request.JSON({ url: url, onSuccess: function(jsonObj){ view_category(jsonObj.selectbar, id); } }).send().chain(function(){ new Fx.Tween(service).start('opacity', '1'); }); } This is the view_category function. Its purpose is to build everything below the select box. It calls the add_select_box. Code: // Viewing the Title, Description and sub descriptions function view_category(oSelect, id){ add_select_box(oSelect, id); oSelect.each(function(oOptions){ if(oOptions.id == id){ var service_type = new Element('div', {id: oOptions.id, 'class': 'sub_choice'}).inject($('ajax_box'), 'bottom'); oOptions.options.each(function(oSub){ var blank_div = new Element('div').inject(service_type, 'bottom'); // Needed for the Expand Link to work var service_title = new Element('h2').set('html', oSub.title).inject(blank_div, 'bottom'); // Title var service_description = new Element('p').set('html', oSub.description).inject(blank_div, 'bottom'); // Description var expand = new Element('div', {'class': 'expanding'}).inject(blank_div, 'bottom'); // Expanding Sub Box if(oSub.sub != undefined){ // Expanding and Colapsing Link var service_elink = new Element('a', {href: 'javascript:void(0)', onclick: 'expand(this); return false'}).set('html', 'more').inject(service_description); oSub.sub.each(function(oSubOptions){ var sub_div = new Element('div').inject(expand, 'bottom'); var sub_title = new Element('h3').set('html', oSubOptions.title).inject(sub_div, 'bottom'); // Sub Title var sub_description = new Element('p').set('html', oSubOptions.description).inject(sub_div, 'bottom'); // Sub description if(oSubOptions.sub_description != undefined){ var sub_elink = new Element('a', {href: 'javascript:void(0)', onclick: 'expand(this); return false'}).set('html', 'more').inject(sub_description); var sub_expanding = new Element('div', {'class': 'expanding'}).inject(sub_div, 'bottom'); // Sub Sub Expanding var sub_sub_description = new Element('p').set('html', oSubOptions.sub_description).inject(sub_expanding, 'bottom'); // Sub Sub Description }; }); }; }); } }); }; This code adds the select box and changes the select box when the select button is changed. Code: function add_select_box(oSelect, id){ var select_box = new Element('div', {id:'select_box'}).inject($('ajax_box')); var formSelectVar = new Element('select'); oSelect.each(function(item){ if(item.id == id){ var continue_div = new Element('div', {id:'continue'}).inject(select_box); new Element('a', {href:'javascript:void(0)'}).inject(continue_div); if(item.id == id){ // Create each option for the first select box item.options.each(function(myArray){ var formOption = new Element ('option').set('html', myArray.title).inject(formSelectVar); }); new Element('option', {selected:'selected'}).set('html', 'Choose').inject(formSelectVar, 'top'); formSelectVar.inject($('select_box'), 'top' ); // This is the First Select Box $('ajax_box').getElement('select').addEvent('change', function(){// Listen for the select box to change var categoryValue = $('ajax_box').getElement('select').value; if($('sub_select')){ var formSelectVar = $('sub_select').set('html', ''); }else { var formSelectVar = new Element('select', {id:'sub_select'}); } // Make a secondary select box for additional options var notdefined; item.options.each(function(myArray){ if(myArray.sub != undefined && myArray.title == categoryValue){ dbug.log('Secondary Select: ', myArray.sub, myArray.title, categoryValue) myArray.sub.each(function(subArray){ var formOption = new Element ('option').set('html', subArray.title).inject(formSelectVar); }); notdefined = false; }else if(myArray.title == categoryValue){ dbug.log('Else Dialoge: ', myArray.sub, myArray.title, categoryValue) notdefined = true; } }); dbug.log('Not Defined: ', notdefined); if(notdefined != true){ new Element('option', {selected: 'selected'}).set('html', 'Choose').inject(formSelectVar, 'top'); formSelectVar.inject($('select_box')); // This is the second select box }else{ formSelectVar.dispose(); } }); }; } }); }; Dear All, I have downloaded some code from a javascript programmers website but having trouble making it work! I have some javascript: [CODE] <SCRIPT TYPE="text/javascript"> <!-- function dropdown(mySel) { var myWin, myVal; myVal = mySel.options[mySel.selectedIndex].value; if(myVal) { if(mySel.form.target)myWin = parent[mySel.form.target]; else myWin = window; if (! myWin) return true; myWin.location = myVal; } return false; } //--> </SCRIPT> [CODE] Within the main body, my code reads: [CODE] <FORM ACTION="../cgi-bin/redirect.pl" METHOD=POST onSubmit="return dropdown(this.gourl)"> <SELECT NAME="gourl"> <OPTION VALUE="">Please select your event... <OPTION VALUE="http://www.yahoo.co.uk"> preview yahoo UK</option> <OPTION VALUE="http://www.yahoo.com"> preview yahoo US</option> <OPTION VALUE="http://www.yahoo.fr"> preview yahoo FR</option> <OPTION VALUE="http://www.expedia.co.uk"> preview Expedia</option> <OPTION VALUE="http://www.travelocity.co.uk"> preview Travelocity</option> <OPTION VALUE="http://www.onlinepictureproof.com"> preview online pics</option> </SELECT> <INPUT TYPE=SUBMIT VALUE="Go"> </FORM> [CODE] On selection of "preview yahoo UK" from drop-down box, it takes me to the correct webpage (www.yahoo.co.uk), so no issue there. However, it opens this page up in a new window. I'm pretty sure this is because the javascript code is telling it to. However, I want the www.yahoo.co.uk page to be displayed in the same window from where the request came from? (i.e. I don't want it to open a new browser window)! What do I have to change in the javascript to make this happen? I tried using the TARGET functionality taught to me many many moons ago, but it still fires up a new window: <OPTION VALUE="http://www.yahoo.co.uk" TARGET="_top"> preview yahoo UK</option> I am testing this on my PC, so perhaps it could be that redirect.pl isn't held locally on my home pc, i.e. it would work once we upload the web pages to the web server?! any help/guidance would be greatly appreciated. I have been using some javascript to select stylesheets (dependent upon window sizes) without problems, until IE8. I have stripped the code down to the following which seems to be where it fails in IE8. Code: <link rel="stylesheet" type="text/css" href="../../css-home.css" title="default" /> <link rel="stylesheet" type="text/css" href="../../css-thin.css" title="thin" /> <link rel="stylesheet" type="text/css" href="../../css-medium.css" title="medium" /> <link rel="stylesheet" type="text/css" href="../../css-large.css" title="large" /> <link rel="stylesheet" type="text/css" href="../../css-home.css" title="normal" /> Code: <script type="text/javascript"> <!-- function changeStylesheet(description){ var i, a; for(i=0; (a = document.getElementsByTagName("link")[i]); i++){ if(a.getAttribute("title") == description){a.disabled = false;} // if the title of the css file is the same as the description, don't disable it else if(a.getAttribute("title") != "default"){a.disabled = true;} // otherwise if the title of the css file is not default, disable it } } function selectLarge(){ changeStylesheet("large"); } selectLarge(); // --> </script> The “normal” stylesheet is the same as “default”. Without this older versions of IE go straight to “large” (without javascript). For these settings, all browsers display the default (or normal?) stylesheet without the script. When the script is run Firefox, Opera and older versions of IE will use the “default” stylesheet combined with the “large” stylesheet. IE8 uses only the “default” and ignores “large”. It doesn’t appear to matter where in the page the script is run. Any suggestions appreciated (it has never worked in Safari, Chrome and older versions of Opera if that helps!). I have a stylesheet switcher which works fine in all mainstream browsers until Safari 5.1 and possibly a past version of Chrome. The source of the problem appears to be in WebKit version 534. Other designers have experienced similar problems: https://discussions.apple.com/thread...art=0&tstart=0 This version of WebKit appears not to action: Code: a.disabled = false in the following script. Code: function changeLayout(description){ var i, a; for(i=0; (a = document.getElementsByTagName("link")[i]); i++){ if(a.getAttribute("title") == description){a.disabled = false;} else if(a.getAttribute("title") != "default"){a.disabled = true;} } } (or perhaps it may be the case that it will only allow one active stylesheet, the default?) I have alternative code I can deliver to switch the stylesheet but it is more onerous and I only want to run it if the usual method would fail. Is there a way I could test if the browser is respecting "a.disabled = false" (or "true" for that matter) and then deliver the alternative code if not? OR is there a reliable way to test for WebKit version 534? Thanks in advance. I have two user agent strings: Code: Mozilla/5.0 (iPad; CPU OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3 Mozilla/5.0 (iPad; U; CPU OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5 The first targets iOS5 and the second targets iOS4. Is it possible to load a custom stylesheet for the first user agent string, then a different one for the later user agent string? 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.
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. Hello, 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 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? 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? 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. 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 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 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> 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! |