crazedcougar
09-09-2006, 07:23 PM
While I was writing I only tested with firefox, it works well on there! However, nothing happens on other browsers.
This code is to change the text in a <P> or <A> tag to a different button. The below script is placed in the header, and run via these:
<body onLoad="setLang(getCookie('lang'), 'selected', 'borderit')">
<a class="borderit" id="1" href="#" onclick="setLang('1', 'selected', 'borderit')"><img src="flag.gif" width="30" alt="en"></a><br \>
<SCRIPT language="javascript">
function setCookie(c_name,value,expiredays){
var exdate=new Date()
exdate.setDate(exdate.getDate()+expiredays)
document.cookie=c_name+ "=" +escape(value)+ ((expiredays==null) ? "" : ";expires="+exdate)
}
function getCookie(c_name)
{
if (document.cookie.length>0)
{
c_start=document.cookie.indexOf(c_name + "=")
if (c_start!=-1)
{
c_start=c_start + c_name.length+1
c_end=document.cookie.indexOf(";",c_start)
if (c_end==-1) c_end=document.cookie.length
return unescape(document.cookie.substring(c_start,c_end))
}
}
return null
}
function setLang(num, class, class2) {
var str1
var str2
document.getElementById(num).blur()
setCookie('lang', num, '100');
for(i=1;i<6;i++){
identity=document.getElementById(i);
identity.className=class2;
}
identity=document.getElementById(num);
identity.className=class;
// graphics done - start text
if (num == 1) {
str1 = "text here"
str2 = "text here"
}
else if (num ==2) {
str1 = "text here"
str2 = "text here"
}
else if (num ==3) {
str1 = "text here"
str2 = "text here"
}
else if (num ==4) {
str1 = "text here"
str2 = "text here"
}
else if (num ==5) {
str1 = "text here"
str2 = "text here"
}
document.getElementById('blurb1').innerHTML=str1
document.getElementById('blurb2').innerHTML=str2
}
</script>
In IE or safari, when clicked they dont become selected, and the strings do not get defined.
You can view a working example here: (no I'm not trying to hype the site)
http://routetruck.com/danEhrlich/index.html
Try it in Firefox, then Internet explorer or safari.
Thanks!
--Peter
PS, is there any good software like firebug that can get errors from IE or safari?
This code is to change the text in a <P> or <A> tag to a different button. The below script is placed in the header, and run via these:
<body onLoad="setLang(getCookie('lang'), 'selected', 'borderit')">
<a class="borderit" id="1" href="#" onclick="setLang('1', 'selected', 'borderit')"><img src="flag.gif" width="30" alt="en"></a><br \>
<SCRIPT language="javascript">
function setCookie(c_name,value,expiredays){
var exdate=new Date()
exdate.setDate(exdate.getDate()+expiredays)
document.cookie=c_name+ "=" +escape(value)+ ((expiredays==null) ? "" : ";expires="+exdate)
}
function getCookie(c_name)
{
if (document.cookie.length>0)
{
c_start=document.cookie.indexOf(c_name + "=")
if (c_start!=-1)
{
c_start=c_start + c_name.length+1
c_end=document.cookie.indexOf(";",c_start)
if (c_end==-1) c_end=document.cookie.length
return unescape(document.cookie.substring(c_start,c_end))
}
}
return null
}
function setLang(num, class, class2) {
var str1
var str2
document.getElementById(num).blur()
setCookie('lang', num, '100');
for(i=1;i<6;i++){
identity=document.getElementById(i);
identity.className=class2;
}
identity=document.getElementById(num);
identity.className=class;
// graphics done - start text
if (num == 1) {
str1 = "text here"
str2 = "text here"
}
else if (num ==2) {
str1 = "text here"
str2 = "text here"
}
else if (num ==3) {
str1 = "text here"
str2 = "text here"
}
else if (num ==4) {
str1 = "text here"
str2 = "text here"
}
else if (num ==5) {
str1 = "text here"
str2 = "text here"
}
document.getElementById('blurb1').innerHTML=str1
document.getElementById('blurb2').innerHTML=str2
}
</script>
In IE or safari, when clicked they dont become selected, and the strings do not get defined.
You can view a working example here: (no I'm not trying to hype the site)
http://routetruck.com/danEhrlich/index.html
Try it in Firefox, then Internet explorer or safari.
Thanks!
--Peter
PS, is there any good software like firebug that can get errors from IE or safari?