tekagami 23 Newbie Poster

1) onkeyup send textarea values to script
2) converts textarea value to array
3) loops thru the array
4) uses regex to check if its an email address
5) changes inner html of recipient div

LastMitch commented: Thanks for the sharing! +12
tekagami 23 Newbie Poster

Introduction
Lets say you have a website with a mobile version and a desktop version. Pictures can be resized proportinally using css on either version. But not all html tags resize proportionally, for instance: iframes.

Javascript Function
includes: the id of the iframe, the original width and original height

See code below.

the iframe

<iframe id="iemovie" onload="resizeiframecent('iemovie','800','450')" src="http://www.youtube.com/embed/J-HieaOI00s?html5=1" width="100%" > </iframe>
  • notice the height is absent but the width is 100%. it will adjust to the parent element's width; usually a div with its preset width, say 800px for desktop, and 90% for mobile.
  • notice the onload attribute
  • when iframe loads the function takes the original proportions oldx and oldy and compares them to the actualwidth
  • the math.ceil funtion rounds up the newheight and creates a new variable called newheight2
    then, the iframe gets a newly defined height atribute based proportionally based on the original height
  • do not set the iframe proportions via css or else you will have to change the code from document.getElementById(ifid).height=newheight2; to document.getElementById(ifid).style.height=newheight2;
LastMitch commented: Nice! +11
Mark_43 commented: This is exactly what I needed. Thank you for your wonderful work +0