Asheh Posted April 4, 2007 Share Posted April 4, 2007 Ok peeps im so confused at javascript I dont know where to start, but anyways im trying to get somthing to display based on the type of browser so i have the following functor: function displayPng(strId, strPath, intWidth, intHeight, strClass, strAlt) { var pngNormal = false; if ((browser.isIE55 || browser.isIE6up) && browser.isWin32) { pngNormal = false; // else, if the browser can display PNGs normally, then do that } else if ((browser.isGecko) || (browser.isIE5up && browser.isMac) || (browser.isOpera && browser.isWin && browser.versionMajor >= 6) || (browser.isOpera && browser.isUnix&& browser.versionMajor >= 6) || (browser.isOpera && browser.isMac && browser.versionMajor >= 5) || (browser.isOmniweb && browser.versionMinor >= 3.1) || (browser.isIcab && browser.versionMinor >= 1.9) || (browser.isWebtv) || (browser.isDreamcast)) { pngNormal = true; } if (pngNormal == false) { alert("nonormal"); document.write('<div style="height:'+intHeight+ 'px;width:'+intWidth+ 'px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+strPath+'.png\', sizingMethod=\'scale\')" id="'+strId+'" class="'+strClass+'"></div>'); } else if (pngNormal) { alert("normal"); document.write('<img src="'+strPath+'.png" width="'+intWidth+'" height="'+intHeight+'" name="'+strId+'" border="0" class="'+strClass+'" alt="'+strAlt+'" />'); } } My first guess was that "alert" is no longer supported by any browsers, but then i tried to actually call the function in code like this: <SCRIPT language="JavaScript"> <!--hide displayPng('','','','','','',''); //--> </SCRIPT> I checked the outputted html but it doesnt display anything but that? Im so confused, how can i call a function inline so that it displays an image based on the browser?? Cheers ??? Quote Link to comment Share on other sites More sharing options...
nogray Posted April 5, 2007 Share Posted April 5, 2007 Here is a small code to check which browser the user uses (from the NoGray Javascript Library) // checking if the browser is Opera var is_Opera = (window.navigator.userAgent.search("Opera") != -1); // checking if the browser is IE var is_IE = ((window.navigator.userAgent.search("MSIE") != -1) && !is_Opera); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.