 |
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

October 24th, 2005, 11:38 AM
|
|
Friend of Wrox
|
|
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

October 24th, 2005, 11:39 AM
|
|
Friend of Wrox
|
|
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
i need it to run on MSIE, FF, NN, SF, MX, DN????
www.crmpicco.co.uk
|
|

October 24th, 2005, 12:58 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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.
|
|

October 25th, 2005, 04:36 AM
|
|
Friend of Wrox
|
|
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

October 25th, 2005, 08:32 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
|
|
> 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
|
|

October 25th, 2005, 10:03 AM
|
|
Friend of Wrox
|
|
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|
 |