?
Solved

JQuery CSS script

Posted on 2013-06-03
3
Medium Priority
?
377 Views
Last Modified: 2013-06-03
HI

I am trying to set some CSS values om an iframe.
However it seems that my JQuery script does not execute.

Can anyone point me in the right direction. Please bare in mind that i am very new to JQuery/Javascript.

 
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
function autoResize(myframe) {
    
	$ww = $(window).width();
	
	
	if(ww < '1000') {
	  wm = (ww + 1000) / 1000;
	  $('#myframe').css({
      'width': '1000px',
	  'height': '200px',
	  'position': 'relative',
	  'top': '0px',
	  '-ms-zoom': wm,
	  '-moz-transform': 'scale('+ wm + ')',
	  '-moz-transform-origin': '0px 0',
	  '-o-transform': 'scale('+ wm + ')',
	  '-o-transform-origin': '0 0',
	  '-webkit-transform': 'scale('+ wm + ')',
	  '-webkit-transform-origin': '0 0'
	  
      });
	  
    } 
    else {
	 $('#myframe').css({
      'width': '1000px',
	  'height': '200px',
	  'position': 'relative',
	  'top': '0px',
	  '-ms-zoom': '1.0',
	  '-moz-transform': 'scale(1.0)',
	  '-moz-transform-origin': '0px 0',
	  '-o-transform': 'scale(1.0)',
	  '-o-transform-origin': '0 0',
	  '-webkit-transform': 'scale(1.0)',
	  '-webkit-transform-origin': '0 0'
	  });
    }
	

}
</script>
<style>
    body{
		margin:0px;
		padding:0px;
	}
	
	#wrap { width: 1000px; height: 200px; padding: 0; position:relative; top:0px; overflow: hidden; background:#666666; }
</style>
</head>

<body>

<div id="wrap">
    <iframe id="myframe"  src="/_adv/edgetest/Untitled-1.html" frameborder="0" onload="autoResize(this);"></iframe>
</div>

</body>
</html>

Open in new window

0
Comment
Question by:kbnewgear
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 39216768
It would be easier to diagnose if you post a link to the page.  As a guess it looks like you are executing the scripting before the page is loaded.  You probably need a $(document).ready()

Cd&
0
 
LVL 18

Expert Comment

by:Rajar Ahmed
ID: 39216821
Try this  changes,
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>
<script type="text/javascript">
    function autoResize(myframe) {
        $ww = $(window).width();
        
        if ($ww < '1000') {
            wm = ($ww + 1000) / 1000;
            $('#myframe').css({
                'width': '1000px',
                'height': '500px',
                'position': 'relative',
                'top': '0px',
                '-ms-zoom': wm,
                '-moz-transform': 'scale(' + wm + ')',
                '-moz-transform-origin': '0px 0',
                '-o-transform': 'scale(' + wm + ')',
                '-o-transform-origin': '0 0',
                '-webkit-transform': 'scale(' + wm + ')',
                '-webkit-transform-origin': '0 0'
            });
        }
        else {
            $('#myframe').css({
                'width': '1000px',
                'height': '500px',
                'position': 'relative',
                'top': '0px',
                '-ms-zoom': '1.0',
                '-moz-transform': 'scale(1.0)',
                '-moz-transform-origin': '0px 0',
                '-o-transform': 'scale(1.0)',
                '-o-transform-origin': '0 0',
                '-webkit-transform': 'scale(1.0)',
                '-webkit-transform-origin': '0 0'
            });
        }
    }
</script>

Open in new window

0
 
LVL 58

Accepted Solution

by:
Julian Hansen earned 2000 total points
ID: 39216838
&cd - he is not invoking the auto-resize event until the iframe loads - so document.ready not required.

Why don't you use dynamic stylesheets to style for different media widths

http://www.w3.org/TR/css3-mediaqueries/
http://css-tricks.com/resolution-specific-stylesheets/

Rather than using JQuery.

Other than that you have an error in your script

$ww = $(window).width()

should be
var ww = $(window).width()
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question