Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript varibles and Iframe

Status
Not open for further replies.

danjudge

Programmer
Nov 20, 2002
2
US
I am trying to access Javascript variables in an Iframe statement to be able to dynamically change the WIDTH and HEIGHT of the iframe based on the current browser window size.

It is for an IE specific browser based application and I am utilizing the following code.

I am a designer with limited programming experience.

The code I have borrowed is IE specific and was told to place it in the body of the html and when the page is resized the iFrame will resize accordingly.

WIDTH=mainWidth and WIDTH=mainHeight does not work of course but this is where I am stuck.

Code:
<body onload=&quot;makeUnits();&quot; onResize=&quot;history.go(0);&quot; scroll=&quot;no&quot;>

<script language=&quot;JavaScript1.2&quot;>

function makeUnits() {

mainHeight = document.body.clientHeight;
mainWidth = document.body.clientWidth;
}
</script>

<DIV class=&quot;mainFrame&quot;>
<IFRAME SRC=&quot;blank.htm&quot; align=&quot;center&quot; NAME=&quot;mainframe&quot; SCROLLING=&quot;No&quot; WIDTH=mainWidth HEIGHT=mainHeight MARGINWIDTH=0 MARGINHEIGHT=0 FRAMEBORDER=&quot;No&quot;></IFRAME>
</DIV>
 
In order for it to work, replace your code by :
Code:
body onload=&quot;makeUnits();&quot; onResize=&quot;history.go(0);&quot; scroll=&quot;no&quot;>

<script language=&quot;JavaScript1.2&quot;>

function makeUnits() {

document.getElementById(&quot;mainframe&quot;).style.height = document.body.clientHeight;
document.getElementById(&quot;mainframe&quot;).style.width = document.body.clientWidth;
}
</script>

<DIV class=&quot;mainFrame&quot;>
<IFRAME id=&quot;mainframe&quot; SRC=&quot;blank.htm&quot; align=&quot;center&quot; NAME=&quot;mainframe&quot; SCROLLING=&quot;No&quot; WIDTH=0 HEIGHT=0 MARGINWIDTH=0 MARGINHEIGHT=0 FRAMEBORDER=&quot;No&quot;></IFRAME>
</DIV>

Now, if I can ask a question, what is the interest of putting an IFRAME that'll take all the place in body ? Why don't you just open &quot;blank.htm&quot; directly in your browser ???
Water is not bad as long as it stays out human body ;-)
 
Targol:

Thanks for the solution.

I found a similar solution since my posting.

In answer to your question, this code sample was simplified just for posting the question.

I am designing the visual interface for an IE based application for a client that will utilize multiple Iframes to load multiple html pages into specifc areas of the screen.

I need a solution like this to help with the liquidity aspect of the design.

The separate hrml pages are utilizing CSS for visual design continuity and will be generated from CGI Perl scripts, flash and traditional html.

I am a desginer used to working in Flash, and utilizing HTMl design packages for my web design work. This is my first serious incursion into the depths of CSS constructed HTML pages and it has been a great adventure.

Thanks for the help.

Danjudge
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top