Tips For Using Internet Explorer Will Appear Here Randomly |
|
Tech-Eclectic Code | |
|
|
|
|
Over 90% of my visitors are using IE as their browser. But I think is a good idea to design your page so it looks similar in the majority of browsers used by your visitors. A simple script will allow you to determine the browser being used, then use this determination in your scripts to display the page more accurately. ( pssst... did you add me to your favorite places yet? )
|
|
|
|
Browser Detection Technique & Use Here is a simple way to determine if vistors are using Netscape as their browser. Set a variable (isNS) true or false based on the application name. var isNS = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) >= 4); You can use this variable to set other actions:
/* They can be used in place of hidden and visible Cross-Browser Compatibility Techniques One of the best methods to determine which browser is being used, especially in javascript functions, is to check how the browser refers to objects. Each of the 3 main browsers use unique ways of refering to objects. Here is a way to determine the browser used:
if (document.layers) { Now that you know how to determine the browser type, you can use variables to hide the differences in object variables between browsers. The following script creates "pre" and "post" variables to disguise object management access differences between the browsers. By hiding the object differences, it makes no difference which browser executes the code.
if (document.layers) { Note that because IE5 supports both getElementById(), and document.all(), the pre and post variables are set twice, once during the document.getElementByID test and again in the document.all test. After setting the pre and post variables, you can reference objects in all three browsers using a simple eval() statement.
var myLayer = eval(pre + 'someLayerID' + post); The preceding code uses the pre and post variables to retrieve a reference to a <div> object whose id is set to "someLayerID". The last line sets the top property to 100. Cross-Browser Window Size Detection IE uses a proprietary property while both Netscape versions favor the W3C's standard properties:
if(document.all) { Because IE uses a body property to determine height and width, you have to execute this script after the body tag, or in the body tag with an onLoad script call. Cross-Browser Rollover Buttons To make buttons change as the mouse moves over them needs to be treated differently depending on the browser in use. You should preload your images for better response, and give each image a unique name. The following function works by determing the browser, and selecting one of two images by name and number. Here is the code for one button. You can have as many as you want, but be aware... the more you have, the slower your page will load.
// Preload Images Here is the link code to activate the onMouseover and onMouseout actions:
<div id="bttn1"> Here is the function to change the image:
function change(layer,Name,Image,No) { In the example above, bttn1 is the layer in which the link is located. If the link is not in a layer, simply send an empty string('') instead of 'bttn1' in the onMouseover and onMouseout calls to the change function.
|
|
|
|
|