tekagami 23 Newbie Poster

tested in Chrome 31.0.16 (windows), IE11 and Firefox 26.

tekagami 23 Newbie Poster

Sometimes a css file wont load because of a slow connection or a conflict between scripts (or just any other reason). This specially problematic on mobile websites (looking at you IOS) where many standards are applied. So this little script will add a link tag to the head tag and load a css file.

This example takes into consideration responsive design. You should modify it to accomodate your design (and file names).

What this script does is take the computed style of a div (poller) and checks if conforms to what is expected from the CSS rules and if not adds a link tag to the head which is selected by checking the page width.

tekagami 23 Newbie Poster

Just change var regMail = /^([_a-zA-Z0-9-]+)(\.[_a-zA-Z0-9-]+)*@([a-zA-Z0-9-]+\.)+([a-zA-Z]{2,3})$/; to

var regMail = /^([_a-zA-Z0-9-]+)(\.[_a-zA-Z0-9-]+)*@([a-zA-Z0-9-]+\.)+([a-zA-Z]{2,7})$/;

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

Your problem is syntaxis try adding the grave accent quote to tablenames and column names.

$strSQL = "SELECT * FROM `employee` WHERE `projmgr` = '$UserName' AND `projname` = '"$_POST["projname"]"' "; 

I would also place the $_POST variable in a regular variable to avoid using extra quotes:

$projname=$_POST["projname"];
$strSQL = "SELECT * FROM `employee` WHERE `projmgr` = '$UserName' AND `projname` = '$projname'"; 
tekagami 23 Newbie Poster
tekagami 23 Newbie Poster

Yeah, chrome (win and ios), IE9 and 10 and safari (win iphone and ipad)

tekagami 23 Newbie Poster

Well in theory any element of html could be resized with it. The key is line 3 of the javascript where the actual size of the element is measured. Everything depends on having the offsetWidth give you a width.

tekagami 23 Newbie Poster

Yes it is

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
tekagami 23 Newbie Poster
<script type="text/javascript">
function switchclass(obj){
	 if (obj.className == 'small'){
	 obj.className = "big";
	 }
	else if (obj.className == 'big'){
	 obj.className = "small";
	 }
    }
</script>
<style>
.small { width: 40px; }
.big { width: 100%; }
</style>
<img src="/picture.jpg" class="small" onclick="switchclass(this);">
<img src="/picture.jpg" class="small" onclick="switchclass(this);">

css is up to you