...

View Full Version : change fonts in javascript??? HELP..



jinger
10-14-2003, 08:59 AM
how can i change my fonts in javascript ??

i found tis following thumbnail javascript:

<script type="text/javascript"><!--

//thumbnail script
thumb=new Image();
thumb2=new Image();
thumb3=new Image();

thumb.src ="art.jpg"
thumb2.src="gypsies.jpg"
thumb3.src="skein.jpg"


document.getElementById("T1").src=thumb.src;
document.getElementById("T2").src=thumb2.src;
document.getElementById("T3").src=thumb3.src;


function thumbtobig(thumbs){
if(thumbs==1){document.getElementById("large").src=thumb.src;ins_text="title1 descriptionssssss";}
//i want to bold the title but leave the descriptions as normal
:confused:

else if(thumbs==2){document.getElementById("large").src=thumb2.src;ins_text="title2 descriptionssssss";}
//i want to bold the title but leave the descriptions as normal
:confused:


else if(thumbs==3){document.getElementById("large").src=thumb3.src;ins_text="title3 descriptionssssss";}
//i want to bold the title but leave the descriptions as normal
:confused:


document.getElementById("caption").replaceChild(document.createTextNode(ins_text), document.getElementById("caption").firstChild);

return false;}

//--></script>

can any experts out there pls help out..

thanks in advance!!:p

Kor
10-14-2003, 10:45 AM
try insert normal HTML tags in string

if(thumbs==1){document.getElementById("large").src=thumb.src;ins_text="<b>title1 descriptionssssss</b>";}

jinger
10-15-2003, 01:54 AM
hmm... i tried inserting the normal HTML tags in string

ins_text="<b>title1 descriptionssssss</b>";}

but the outcome would be like
"<b>title1 descriptionssssss</b>"

the tags are shown together with the descriptions.
Are there anymore of ur precious solutions? :confused:

thanks!

Willy Duitt
10-15-2003, 04:04 AM
This looks familar:

title1 descriptionssssss

jinger
10-15-2003, 04:17 AM
yes :rolleyes:

if its familar, den can someone pls help or there are any good tutorials to recommend? abt tis topic..

Willy Duitt
10-15-2003, 06:30 AM
Try:

if(thumbs==1){document.getElementById("large").src=thumb.src;ins_text="'<b>'+title1 descriptionssssss+'</b>'";}

....Willy

jinger
10-15-2003, 06:59 AM
Originally posted by Willy Duitt
Try:

if(thumbs==1){document.getElementById("large").src=thumb.src;ins_text="'<b>'+title1 descriptionssssss+'</b>'";}

....Willy

it also share the same results as the pervious one...:(

Kor
10-15-2003, 08:02 AM
try using styles on-the-fly:



if(thumbs==1){
document.getElementById("large").src=thumb.src;
document.getElementById("large").style.fontWeight="bold";
ins_text="+title1 descriptionssssss+";
}

jinger
10-15-2003, 08:44 AM
err..
it still doesnt work.. my code is originated from the following attachment~

does it mean tat i can only use normal default plain text?

jinger
10-15-2003, 10:09 AM
is there by any chance tat i can use array for this script?

like that:

var messages=new Array()
messages[0]="<font size='1' face='Verdana'><a href='http:///'><b>title</b></br>all the descriptions</a></font>"

messages[1]="<font size='1' face='Verdana'><a href='http:///'><b>title</b></br>all the descriptions</a></font>"

messages[2]="<font size='1' face='Verdana'><a href='http:///'><b>title</b></br>all the descriptions</a></font>"

juz a wild guess... ;)

Willy Duitt
10-15-2003, 10:54 AM
Untested


<script type="text/javascript">
function thumbtobig(thumbs){

var messages=new Array()

if(thumbs==0){
messages[messages.length] = new Array("art.jpg","<font size='1' face='Verdana'><b>title</b></br>all the descriptions</font>");
document.getElementById("T1").src=messages[0];
document.getElementById("ins_text").innerHTML=messages[1];
}

else if(thumbs==1){
messages[messages.length] = new Array("gypsies.jpg","<font size='1' face='Verdana'><b>title</b></br>all the descriptions</font>");
document.getElementById("T2").src=messages[0];
document.getElementById("ins_text").innerHTML=messages[1];
}

else if(thumbs==2){
messages[messages.length] = new Array("skein.jpg","<font size='1' face='Verdana'><b>title</b></br>all the descriptions</font>");
document.getElementById("T3").src=messages[0];
document.getElementById("ins_text").innerHTML=messages[1];
}
}

jinger
10-16-2003, 10:13 AM
thanks for the reply but, more errors came up....

it says:

'document.getElementById(...)' is null or not an object
for the below codes...

document.getElementById("T1").src=thumb1.src;
document.getElementById("T2").src=thumb2.src;
document.getElementById("T3").src=thumb3.src;
document.getElementById("T4").src=thumb4.src;



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum