Web Analytics Made Easy -
StatCounter Script Inside Iframe bugs terribly - CodingForum

Announcement

Collapse
No announcement yet.

Script Inside Iframe bugs terribly

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

  • Script Inside Iframe bugs terribly

    I have an iframe nav system, each nav link calls a function passing an argument, then the funtion rewrites the nav table, making the clicked link selected and all others normal and so on. It works fine, however, this script in the end should actually load the requested page into the parent of this nav frame. All i get is crap, the main page loads inside the iframe, here is the funtion:


    function gotoPage(id) {
    var nameArr = new Array("Home", "Articles", "Experiments", "Links", "About")
    var linkArr = new Array("index.html", "HTML/articles.html", "HTML/experiments.html", "HTML/links.html", "HTML/about.html")
    window.parent.location = linkArr[id]
    if (document.getElementById){
    x = document.getElementById(id);
    //alert(x.innerHTML)
    x.innerHTML = '';
    x.innerHTML = '<div class="selTab">'+nameArr[id]+'</div>';
    for(j=0; j<5;j++){
    if(j!=id){
    x = document.getElementById(j);
    x.innerHTML = '';
    x.innerHTML = '<a onclick="gotoPage('+j+');" href="#">'+nameArr[j]+'</a>';
    }
    }
    }
    else if (document.all){
    x = document.all[id];
    x.innerHTML = '<div class="selTab">'+nameArr[id]+'</div>';
    for(j=0; j<4;j++){
    if(j!=id){
    x = document.all[j];
    x.innerHTML = '<a onclick="gotoPage('+j+');" href="#">'+nameArr[j]+'</a>'
    }
    }
    }

    }
    </code>

  • #2
    try using

    parent.location.href

    instead of

    window.parent.location
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

    Comment


    • #3
      unfortunately parent.location.href does not work either.
      It may be obvious, but what happens when you reload the parent when there is an iframe inside? does it reset the iframe? because if it does then there is no use in iframe, hope not, however, i worked hard to get the code working

      Comment


      • #4
        does it reset the iframe?
        Of course. Isn't that what you want?
        KOR
        Offshore programming
        -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

        Comment


        • #5
          noooooooooo
          Look, there is a parent page which holds the content. There is also an iframe on this main parent page. When the user click in the iframe, on 'Links' for example, I need to remove the href from the Links in the iframe because this page will open and I need to load the Links.html file in the parent window. My script changes the style fine but as soon as the links page loads the iframe gets reset (as you said) and I loose the scripts work, all links are present AND the Links.html has loaded inside the iframe too (whyyyy?????)

          Comment


          • #6
            Let me see:You want to:

            - open a page in iframe
            - when open the page, the correspondent link on parent menu should loose the href (or should change the style in a certain way).
            - when open another page, do the same, but the previous link in menu should came to initial state.

            Is thi all?
            KOR
            Offshore programming
            -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

            Comment


            • #7
              the answer to why should be simple your reloading the document that holds the iframe as far as I understood.

              Comment

              Working...
              X