Javascript - how to display a given text as string -


i learning javascript during free time. part of small project, wanted users youtube video id, width , height using html form , use write in below format.

for example, if user inputs width = 640, height = 360 , video id = ibogovrkfje, final output below:

<iframe width="input_width" height="input_height" src="http://www.youtube.com/embed/input_videoid?rel=0" frameborder="0" allowfullscreen></iframe> 

when used document.write below not processed since 2 double quotes come together.

document.write "<iframe width=""; 

so, used html ascii " double quotes

document.write "<iframe width=&#34;"; 

now problem ;

the ascii ; &#59; 

i totally @ loss, don't know how proceed, have been working on week.

sorry not point question , or alternative in regard appreciated.

thanks!

either escape doublequote:

document.write("<iframe width=\""); 

or use different types of quotes:

document.write('<iframe width="'); 

or:

document.write("<iframe width='"); 

you forgot parentheses around parameter list.

for second problem, solution use entity code ampersand:

the ascii ; &amp;#59; 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -