Jump to content
xisto Community
logophobia

Need Help With This Javascript

Recommended Posts

I have this small javascript that is supposed to resize an iframe. It works when I replace the var name with normal numbers but not with a variable input. Could someone help me out pls? Here is the script:<script type="text/javascript">var forumheight = window.height - 120;document.write("<iframe src=\"http://forums.xisto.com/no_longer_exists/; width=\"99%\" height=\"" + forumheight + "\"></iframe>");</script>thx in advance

Share this post


Link to post
Share on other sites

nonono, nevermind. i meant if you replaced the var in the document.write with a number. Its meant to resize an Iframe to fit in the window. It works now just in firefox, not in IE. IE seems to ignore the width settings. Could anyone help me with this:<script type="text/javascript">var myHeight = 0;var myWidth = 0;if( typeof( window.innerWidth ) == 'number' ) {myHeight = window.innerHeight;myWidth = window.innerWidth;}else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {myHeight = document.documentElement.clientHeight;myWidth = document.documentElement.clientWidth;}else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {myHeight = document.body.clientHeight;myWidth = document.body.clienWidth;}else{myHeight = window.height;myWidth = window.width;}myWidth = myWidth - 4;myHeight = myHeight - 133;document.write("<iframe src=\"http://forums.xisto.com/no_longer_exists/; width=\"" + myWidth + "\" height=\"" + myHeight + "\"></iframe>");</script>

Share this post


Link to post
Share on other sites

Good news !!

I was integrating your script in a basic HTML page and I found the anomaly !
Go to the line 15 and correct it like this

myWidth = document.body.clientWidth;
You only forgot the "t" of "client". <_<

I recommend you to debug your program with command like alert('...') in JavaScript, it helps to localize little bugs in all scripts :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.