?
Solved

Passing variables to iframe src

Posted on 2003-02-21
6
Medium Priority
?
242 Views
Last Modified: 2010-08-05
<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
0
Comment
Question by:rowghani
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 4

Expert Comment

by:jonnal
ID: 7994273
hi try

<script>document.write(clientWidth)</script>
0
 
LVL 5

Accepted Solution

by:
cirtap earned 150 total points
ID: 7999379
Hi,
I don't think you'll get around with at least two requests for the "banner" page, but in case there's no JS vailable, banner.asp can serve a default size in case the Script will be able to provide the clientWidth.
As I don't know if your banner is just the "top of your page" or an ad-link, I'll assume the latter.
Ad-Pages normally refresh themselves using <meta refresh>. I'll suggest you make "banner.asp" create a "blank page" upon first request (no args/params given) incl. a refresh of let's say 2 seconds just to load quickly and wait "what comes next".
If JavaScript is available, the script will in the "hosting page" will immediately change the banner's location with the clientWidth parameter and from this point on, banner.asp will refresh itself with ?clientWidth and whatever additional informations it needs; next banner-id etc.

The page hosting the banner:
...
<td class="bannerTD">
<!-- 1. the IFRAME with NO -->
<iframe name="banner" class="bannerIF" frameborder="no" src="banner.asp" scrolling="no"></iframe>
<!-- 2. the script FOLLOWING the IFRAME -->
<script language="JavaScript">
<!--
  // I guess this needs a fix-up to work in NS as well!
  var clientWidth = document.body.clientWidth;
  // now set the location
  banner.window.location.href="banner.asp=?clientWidth" + clientWidth;
// -->
</script>
</td>
...

However, I'd NOT use document.write() to create the <IFRAME> from script to avoid the first (kinda useless) request, but it's up to you.

Hope this helps.
CirTap
0
 

Author Comment

by:rowghani
ID: 8009228
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>
0
WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

 
LVL 5

Expert Comment

by:cirtap
ID: 8011593
:-) 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
0
 

Author Comment

by:rowghani
ID: 8016877
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

0
 
LVL 5

Expert Comment

by:cirtap
ID: 8025378
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
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question