IPB

Welcome Guest ( Log In | Register )



Tags
This content has not been tagged yet
 
Reply to this topicStart new topic

Need Help With This Javascript


logophobia
no avatar
Member [Level 2]
*****
Group: Members
Posts: 86
Joined: 19-October 04
Member No.: 1,832



Post #1 post Oct 22 2004, 11:14 PM
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://tim.trap17.com/forum/\" width=\"99%\" height=\"" + forumheight + "\"></iframe>");
</script>

thx in advance
Go to the top of the page
+Quote Post
logophobia
no avatar
Member [Level 2]
*****
Group: Members
Posts: 86
Joined: 19-October 04
Member No.: 1,832



Post #2 post Oct 23 2004, 12:30 AM
sr, fixed it. Saw something on the internet that helped. smile.gif
Go to the top of the page
+Quote Post
LuciferStar
no avatar
Advanced Member
*******
Group: Members
Posts: 114
Joined: 9-August 04
From: Suzhou Jiangsu China
Member No.: 743



Post #3 post Oct 23 2004, 07:58 AM
Do you mean this:[br]
CODE
[/br]function change(var x)[br]{[/br]var forumheight = x;[br]document.write("<iframe src=\"http://tim.trap17.com/forum/\" width=\"99%\" height=\"" + forumheight + "\"></iframe>");[/br]}
Go to the top of the page
+Quote Post
logophobia
no avatar
Member [Level 2]
*****
Group: Members
Posts: 86
Joined: 19-October 04
Member No.: 1,832



Post #4 post Oct 23 2004, 11:46 AM
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://tim.trap17.com/school\" width=\"" + myWidth + "\" height=\"" + myHeight + "\"></iframe>");
</script>
Go to the top of the page
+Quote Post
logman92
no avatar
Newbie [Level 1]
*
Group: Members
Posts: 10
Joined: 22-October 04
From: Paris, France
Member No.: 1,880



Post #5 post Oct 23 2004, 01:10 PM
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
CODE
myWidth = document.body.clientWidth;

You only forgot the "t" of "client". wink.gif

I recommend you to debug your program with command like alert('...') in JavaScript, it helps to localize little bugs in all scripts cool.gif
Go to the top of the page
+Quote Post
logophobia
no avatar
Member [Level 2]
*****
Group: Members
Posts: 86
Joined: 19-October 04
Member No.: 1,832



Post #6 post Oct 23 2004, 03:40 PM
thx alot. Ill try that smile.gif
Go to the top of the page
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

    Topic Title Replies Topic Starter Views Last Action
No New Posts   10 Vacant 5,848 3rd June 2009 - 05:11 PM
Last post by: proskiier23
No New Posts 10 holyium 10,349 25th September 2004 - 12:33 AM
Last post by: spyshow
No New Posts   3 Vacant 8,119 26th August 2004 - 09:09 AM
Last post by: Vacant
No New Posts 2 reciter 10,121 30th January 2005 - 06:17 AM
Last post by: jordanliuhao
No New Posts 5 reciter 3,760 14th January 2005 - 08:16 PM
Last post by: MaRiOnI
No New Posts   7 Mike 4,507 30th April 2009 - 10:32 PM
Last post by: webishqiptar
No New Posts   2 kvarnerexpress 3,130 5th June 2009 - 03:06 PM
Last post by: k_nitin_r
No New Posts 3 nancmu 6,646 14th January 2005 - 09:02 PM
Last post by: vizskywalker
No New Posts   2 solankyno1 4,673 17th January 2005 - 10:07 PM
Last post by: alapidus
No New Posts   3 MacFly 3,414 23rd January 2005 - 06:22 AM
Last post by: LuciferStar
No New Posts 1 clemen 9,357 24th February 2005 - 01:42 AM
Last post by: ill
No New Posts   8 ppj 2,208 18th April 2005 - 07:53 PM
Last post by: wariorpk
No New Posts 0 andrewsmithy 2,070 19th March 2005 - 04:46 AM
Last post by: andrewsmithy
No new 19 andrewsmithy 14,465 11th February 2010 - 08:50 PM
Last post by: iG-wem
No New Posts   2 AskAndrewD 1,101 7th November 2007 - 08:21 PM
Last post by: Paul1582


 



RSS Open Discussion Time is now: 21st March 2010 - 08:23 PM

Web Hosting Powered by ComputingHost.com.
Xisto.com : HONESTY ROCKS! truth rules.
Creative Commons License