Web Analytics Made Easy -
StatCounter Targeting iframe - CodingForum

Announcement

Collapse
No announcement yet.

Targeting iframe

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Targeting iframe

    Can someone help me out with this? I have two pages set up:
    1) main.htm (home page), and
    2) fy04/index.htm (contains iframe)

    Index.htm has an iframe with the following code:
    <iframe name="cwindow" style="border:5px ridge white" width=350 height=350 src="header.htm"></iframe>

    This index.htm page is set up as a table. The left side has eight links listed and the right side is the iframe that the links open into. The src = "header.htm" is just a static info page that loads when the page is opened. When you click on link1.htm it opens up in the iframe. Same with link2 through link8 using <a href="link#.htm" target="cwindow">

    These same eight links are also listed on my main.htm page. I want to have each of those links go to the index.htm page and open their respective file in the iframe. I'm not sure how to set up the link on the main.htm page. Link 1 needs to go to fy04/index.htm, then open link1 in the iframe. Can anyone tell me how to do this?

  • #2
    main.htm:
    <a href="fy04/index.htm?link1.htm">link 1</a>
    <a href="fy04/index.htm?link2.htm">link 2</a>
    <a href="fy04/index.htm?link3.htm">link 3</a>
    ...

    index.htm:
    <script type="text/javascript">
    function loadIFrame(){
    if (location.search) window.open(location.search.substring(1),'cwindow');
    }
    </script>
    </head>
    <body onload="loadIFrame()">
    <iframe name="cwindow" style="border:5px ridge white" width=350 height=350 src="header.htm"></iframe>
    </body>
    Glenn
    vBulletin Mods That Rock!

    Comment


    • #3
      Thanks Glenn,
      I tried that and it looked like it was going to work fine but I ran into a problem. My pages sit in a sub-web of a main portal. Rules dictate that all pages call on a .js script to automatically load the top and left navigation to all pages to keep the look consistent. We can modify the left nav to suit our sub-webs but have no control over the top nav. When I added your script to the head of my index.htm file and then added the <body onload="loadIFrame()"> code, it called an additional set of top & side navs to my page so there must be a conflict with the .js file.

      Is there any way to work around that? If not, I'll have to come up with some other way to put my content out there. Too bad...the iframe seemed like a perfect fit.

      In any event, thanks so much for your help. That's the closest that I've come to getting this to work!

      -Cha

      Comment


      • #4
        I didn't quite understand this:
        When I added your script to the head of my index.htm file and then added the <body onload="loadIFrame()"> code, it called an additional set of top & side navs to my page so there must be a conflict with the .js file.
        Glenn
        vBulletin Mods That Rock!

        Comment


        • #5
          Sorry. Let me try and explain it better.

          There is a web 'portal' that everyone in my work group uses to build their own webs. Everyone that posts web pages can customize their pages with whatever content they want. To keep uniformity, we're required to use a template that essentially looks blank, but includes a .js file that automatically loads a top banner and side navigation. Here's a sample of the script:

          <!--Start: ToolBar V2.0-->
          <script language="javascript" src="http://portal.ts.com/lib/navigation/header.js"></script>
          <script language="javascript" src="../../../_borders/local3.js"></script>

          <!-- Start: ToolBar for down-level browsers--><span id="TBDownLevelDiv">
          <h1>Currently only IE 4 and greater are supported!</h1></span><!-- End: ToolBar For down-level browsers-->
          <p>
          <script language="javascript">
          <!--// Hide from old browsers
          var ToolBar_Supported = ToolBar_Supported;
          if (ToolBar_Supported != null && ToolBar_Supported == true)
          {
          TBDownLevelDiv.style.display ='none';
          drawHeader();
          }
          //-->
          </script>

          This calls the two .js files (local3.js and header.js) and the proper header and left navigation bar appear when your pages are published or previewed.

          When I added your script to my page, and previewed it, there were then two headers and two left navigation panels on my page, instead of just one each. I was thinking maybe the 'onload' function was in conflict with something.

          Does this make more sense? Or am I having a blond moment and confusing you even more?

          Thanks again for your help. No one else here adds js to their pages (cowards) and I use it all the time - but am self-taught and am not well versed enough in it when it comes to solving problems beyond the basics.

          -Cha

          Comment


          • #6
            Do the link#.htm pages also call those 2 .js files?

            I don't think that you would have 2 set of navigation panels when calling loadIFrame() on onload of index.htm even if it has onload conflict with those .js files. It's hard to picture it without seeing it online. Do you have any link?
            Glenn
            vBulletin Mods That Rock!

            Comment


            • #7
              Unfortunately its an (intranet) internal site and sits behind a firewall so a link would be worthless.

              In answer to your question, all of the pages call those .js files. I thought I read somewhere when I searched the forum that 'onload' could cause a conflict if there was more than one call for it on a page. With the exception of having those duplicate panels showing up, your script did work, because link1, link2, etc. did load into the iframe when launched from the main.htm file. I just can't figure out why the dupliate nav panels are coming up. The only difference on that page is the short js in the header that you recommended and the onload code in the body.

              Comment


              • #8
                If indeed the link#.htm pages call those 2 .js files, then the iframe (located in index.htm with navigation links) where link#.htm pages are loaded will also definitely contain those navigation links.
                Glenn
                vBulletin Mods That Rock!

                Comment

                Working...
                X