Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 24th, 2005, 11:38 AM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default make javascript cross-browser

Does anyone know the best way to make my javascript cross-browser?

Here is some sample code from my scripting:

Code:
if(noc > 1)
{
    for(i=1; i<=noc; i++)
    {            
        for(ic=1; ic<=noc; ic++)
        {                
            tt1 = document.getElementById("ctitle"+i);
            tt2 = document.getElementById("ctitle"+ic);
            fn1 = document.getElementById("cfname"+i);
            fn2 = document.getElementById("cfname"+ic);
            lm1 = document.getElementById("clname"+i);
            lm2 = document.getElementById("clname"+ic);    

            if (i!=ic)
            {        
                  if ((tt1.value==tt2.value) && (fn1.value==fn2.value) && (lm1.value==lm2.value))                                            
                  {
                      alert("You must not enter two identicle child names, please re-enter");
                    return false;
                  }
            }                                
        }                
    }
}

FUNCTION NAME: message_help
Create information to be displayed inside hidden 'info'
table row. eg. Airline Name, Seat Information or Airport Name etc.
*/
function message_help(message,pass,passNo,info)
{
    var doc = document.form;
    var df = document.forms["form"];

    var segments = doc.segments.value;

    var ad = doc.noa.value;
    var ch = doc.noc.value;

    /* ADULT PROCESSING FOR 'SEAT INFO' TABLE ROW */
.......

....
TIA.

Picco

www.crmpicco.co.uk
__________________
_______________________
Ayrshire Minis - a Mini E-Community
http://www.ayrshireminis.com
http://www.crmpicco.co.uk
Reply With Quote
  #2 (permalink)  
Old October 24th, 2005, 11:39 AM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

i need it to run on MSIE, FF, NN, SF, MX, DN????

www.crmpicco.co.uk
Reply With Quote
  #3 (permalink)  
Old October 24th, 2005, 12:58 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

And does it work in all those browsers? If not, what's the problem?

You need to provide a little more information. I don't think anyone here has the time to play hide and seek, where you hide the problems and we need to find them....

The best way for cross browser support is to stick to the standards and test.... getElementById is a good cross browser way in recent (and a bit older) browsers to get a reference to an element, so that's a good start.

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #4 (permalink)  
Old October 25th, 2005, 04:36 AM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

thanks, i was thinking about things like document.forms["form"] and document.form as well? are they cross-browser in the same fashion as getElementByID?

www.crmpicco.co.uk
Reply With Quote
  #5 (permalink)  
Old October 25th, 2005, 08:32 AM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

> thanks, i was thinking about things like document.forms["form"] and document.form as well? are they cross-browser in the same fashion as getElementByID?

Why don't you answer your own question by testing it in various browsers? Many of the questions that you ask can be answered on your own with a little experimentation. Pull up the document in Firefox, Opera, et all, and see if it works! If it doesn't, have a look at the JavaScript error console in each respective browser.

Having said that; document.forms[] and document.form[] are relics of JavaScript past and are quite well supported. Those go all the way back to NN 2 and IE 3. In fact, only when you venture towards doing something advanced does javascript compatibility become a problem. i.e. finding the mouse cursor's position, advanced DOM (where Explorer has loads of nifty properties and methods that aren't cross-browser), getting selected text, some aspects of XMLHttpRequest, etc. Many websites exist to inform us of these differences. One such site is quirksmode.org.

Regards,
Rich

--
[http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design
Reply With Quote
  #6 (permalink)  
Old October 25th, 2005, 10:03 AM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

hi richard, i have ran my code on different browsers, other than what it was built for (IE) - mainly FF and NN. I have this piece of code:
Code:
<SCRIPT ID="script" FOR="submit_button<%=uniqueCount%>" EVENT="onclick()">
javascript: return chkSel('<%=leg1%>','<%=leg2%>','<%=leg3%>','<%=uniqueCount%>');
</SCRIPT>
Which runs in IE, but thats it. What i wanted to know was other than this what other pieces of code will not run on other non-IE browsers? Just a general discussion and I was looking for pointers.

www.crmpicco.co.uk
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cross browser compatibility hussainm BOOK: Professional Ajax ISBN: 978-0-471-77778-6 3 December 4th, 2006 07:34 AM
Handle Sessin in browser cross button click ashish2001mca General .NET 1 February 9th, 2006 10:28 AM
Designing for cross browser site joefawcett CSS Cascading Style Sheets 3 June 22nd, 2005 08:09 AM
Cross Browser DHTMLMenu flash2004 Javascript 0 March 30th, 2005 02:30 AM
CROSS-PLATFORM javascript y_simonson XSLT 2 January 13th, 2004 05:16 PM



All times are GMT -4. The time now is 02:44 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.