tool bar (javascript)

Discussion in 'JavaScript' started by wordgeist, Apr 25, 2010.

  1. #1
    Hi,

    I'm trying to implement a tool bar. I found this code ( http://www.amirharel.com/2009/07/28/implementing-iframe-toolbar/):


    
    <html>
    <head>
    <script
    $(document).ready(main);
    
    function main()
    {
    	$('iframe').attr('src', getIframeUrl() );
    	registerEvents();
    	resizeIframe();
    }
    
    function getIframeUrl()
    {
    	var url = window.location.href;
    	var iframe_url = 'http://www.nowaythatthereissomethinghere.com';
    	var param_start = url.indexOf("iframe=");
    	if( param_start != -1 )
    		iframe_url = url.substr(param_start+7,url.length-param_start-7);
    	if( iframe_url.indexOf("http://") == -1)
    		iframe_url = "http://" + iframe_url;
    
    	return iframe_url;
    }
    
    function resizeIframe()
    {
    	$("#iframe").height( WindowHeight() - getObjHeight(document.getElementById("toolbar")) );
    }
    
    function WindowHeight()
    {
    	var de = document.documentElement;
    	return self.innerHeight ||
    		(de &amp;amp;amp;&amp;amp;amp; de.clientHeight ) ||
    		document.body.clientHeight;
    }
    
    function getObjHeight(obj)
    {
    	if( obj.offsetWidth )
    	{
    		return obj.offsetHeight;
    	}
    	return obj.clientHeight;
    }
    
    $(window).resize( function() {resizeIframe();} );
    
    </script>
    </head>
    
    <body>
    	<div id='toolbar'>
    		<div id='search'>
    			<input id='qs' type='text' size='35' ></input>
    			<input type='button' value='search' id='searchBtn' ></input>
    		</div>
    		<div id='main'>
    			<div id='links'>
    				<a id='back' href='javascript:void(0);'>Go back</a>
    				<a id='twitter' href='javascript:void(0);'></a>
    				<a id='arrow' href='javascript:void(0);'></a>
    				<a id='close' href='javascript:void(0);'></a>
    			</div>
    			<div id='extra'>
    			<br>
    			Is that alright? Give my gun away when it's loaded <br>
    			Is that alright? If you don't shoot it how am I supposed to hold it <br>
    			Is that alright? Give my gun away when it's loaded <br>
    			Is that alright With you?
    			</div>
    		</div>
    
    	</div>
    	<div id='iframe'>
    		<iframe src='' />
    	</div>
    </body>
    </html>
    
    
    Code (markup):

    this is not working as it should but I can not find the error. Any of you can tell me what I'm doing wrong?
     
    wordgeist, Apr 25, 2010 IP
  2. dimitar christoff

    dimitar christoff Active Member

    Messages:
    882
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #2
    this is using jquery, i take it you have the framework running ok? if you want meaningful help, saying things like 'this does not work as it should' won't help, instead, try to be more specific like 'it's supposed to open up an iframe from such asn such url but instead, nothing happens and i get an javascript exception on line nn with the following code "paste here"'
     
    dimitar christoff, Apr 26, 2010 IP