Link to home
Start Free TrialLog in
Avatar of rowghani
rowghani

asked on

Passing variables to iframe src

<body>
    ......
   <td class="bannerTD">
      <script>
     var clientWidth = document.body.clientWidth;
      </script>
     <iframe name="banner" class="bannerIF" frameborder="no" src="banner.asp?clientWidth=" + <script>clientWidth</script> scrolling="no">
      </iframe>
   </td>

......
</body>

As you can see im trying to pass the variable clientWidth to my asp page as an argument, except when i check in the asp page, clientWidth is equal to "" and not the proper value.......Thanks in advance
Avatar of jonnal
jonnal

hi try

<script>document.write(clientWidth)</script>
ASKER CERTIFIED SOLUTION
Avatar of Member_2_547613
Member_2_547613
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rowghani

ASKER

thanks to everybody for their help, i got it after several tries:

<td class="bannerTD">
     <script>
     var source = "banner.asp?clientWidth=" + document.body.clientWidth;
        document.write("<iframe name='banner'   class='bannerIF' frameborder='no' src='"+ source +"' scrolling='no'></iframe>");
     </script>
</td>
:-) looks familiar
and makes your banner's appearance depend on JavaScript.
you may want to think a minute about my previous comment and what possibilities and flexibility you'll gain from it.

Have phun
CirTap
thanx cirtap,
the thing is that this script is not being used on the World Wide Web (ie. a homepage or whatnot). My company has enbeded IE in their application, and im creating a web user interface for our clients. We require that the client have IE, and therefore the banner page's appearance depending on javascript is ok.

Maybe you have some other issue about having Javascript depended page, and i would love to hear them!
Cheers

Hi,
well thanx 4 the points then.

If you'd mentioned the intranet before... Things are *always* totally different in such a controlled environment and using document.write becomes a pretty "save" way (for the programmer/designer) to solve "problems", although not the only one.
As a hint for your (maybe) upcoming questions in EE: make clear it's for MSIE (version maybe?) in an intranet-site so the experts can give you more specific answers instead of 'generic', x-browser, www-compatible ones :-)

I don't know if disabling Scripting in MSIE itself will also affect any embedded WebBrowser-Control (WBC). If so, the "plain banner-call" may detect this and display a message. You may want to this this out.

'My' answer to JS dependant pages is simple: avoid to make one :-) in www.
No JS validation in FORMs without having validation on the server,too, no JS-only navigation, if it will make browsers w/o JS stop from accessing the site's (well planned and large) content.
Building a website is like cooking: using exotic spices are great fun - but sometimes all you need is some salt and pepper to enjoy the food.

If you "depend" solely on MSIE, go to the 'Web Develpment' area of MSDN library and check out the great extra features IE and the WBC provide compared to other browsers; HTML behaviors, HTML components, and many useful additional events, XML integration etc.
http://msdn.microsoft.com/library/default.asp

Have fun,
CirTap