Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. I Frame code to replace "name" attribute

I Frame code to replace "name" attribute

Scheduled Pinned Locked Moved JavaScript
helpjavajavascriptdata-structurestools
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    PDTUM
    wrote on last edited by
    #1

    Good Morning...I have been using the name attribute (for years) to call an aspx page to load in an iFrame, and it's works perfectly. Unfortunately, it throws a warning that this is an outdated code method and should be replaced. I am sure this is an old story to most Java developers (I am not one), but old habits (especially one's that work perfectly) die hard. So, I decided to move forward and use a newer code call so my code would compile perfectly clean (error and message wise). The catch is that nothing that I have tried works. They all load the page, but none load the page in the frame. Obviously, there is a syntax issue that I am missing. Here is my latest attempt:

    <%--Change Page Content in iFrame--%>
    <script type="text/javascript">
    var newPage = document.getElementById('iFrame');
    function ChangePage(newPage) { iFrame.src = 'iHome.aspx' };
    </script>

        //Contents for menu 1 (Home)
        var menu1 = new Array()
        menu1\[0\] = '<a href="iHome.aspx" target="javascript:ChangePage(newPage)" onclick="javascript:ChangeLabel(home)">Home</a>'
    

    So....all this to basically replace (target="f1"), where f1 was the name attribute of the frame (now deleted)...Go Figure. A slice of code here would be much appreciated. Thanks for your help...Pat

    T 1 Reply Last reply
    0
    • P PDTUM

      Good Morning...I have been using the name attribute (for years) to call an aspx page to load in an iFrame, and it's works perfectly. Unfortunately, it throws a warning that this is an outdated code method and should be replaced. I am sure this is an old story to most Java developers (I am not one), but old habits (especially one's that work perfectly) die hard. So, I decided to move forward and use a newer code call so my code would compile perfectly clean (error and message wise). The catch is that nothing that I have tried works. They all load the page, but none load the page in the frame. Obviously, there is a syntax issue that I am missing. Here is my latest attempt:

      <%--Change Page Content in iFrame--%>
      <script type="text/javascript">
      var newPage = document.getElementById('iFrame');
      function ChangePage(newPage) { iFrame.src = 'iHome.aspx' };
      </script>

          //Contents for menu 1 (Home)
          var menu1 = new Array()
          menu1\[0\] = '<a href="iHome.aspx" target="javascript:ChangePage(newPage)" onclick="javascript:ChangeLabel(home)">Home</a>'
      

      So....all this to basically replace (target="f1"), where f1 was the name attribute of the frame (now deleted)...Go Figure. A slice of code here would be much appreciated. Thanks for your help...Pat

      T Offline
      T Offline
      twseitex
      wrote on last edited by
      #2

      Hi, var newPage = document.getElementById('iFrame'); // get a pointer of object with ID attribute and value "iframe" if(newPage!=null) // check pionter ! { // do domething } // so put this code in a function function getPointerOfObject_ID(stID) // stID value of ID attribute, not of name attribute { var ptOfObject=null; if(stID!=null) {if(stID!="") {ptOfObject=document.getElementById(stID);} } return ptOfObject; } // only an example -------------------------------------------------------------------------------------------------------------------------- function ChangePage(newPage) // newPage not in use { iFrame.src = 'iHome.aspx' // Object with pointer iFrame must exists // Object with pointer iFrame must have property .src // to get a pointer of an object see getPointerOfObject_ID(stID) }; ----------------------------------------------------------------------------------------------------- menu1[0] = 'Home'; ChangePage(newPage) --> newPage not in use inside of ChangePage() ChangeLabel(home) --> home is a string var ? ID attribute of A-tag not exist. ------------------------------------------------------------------------------------------------------- to get pointer with ID or NAME // +++++ check Microsoft Internet Explorer function fuIEexist() { var X00=false; X00=(navigator!=null); if(X00){X00=(navigator.appName!=null);} if(X00){X00=(navigator.appName.length>0);} if(X00){X00=(navigator.appName.indexOf("Microsoft")!=-1);} return X00; // true for exist } // +++++ get reference function fuGetReference(X00) // X00 string, value of ID or NAME { var X01=null; if(X00!=null) {if(X00.length>0) { if(fuIEexist()) {X01=window[X00]; if(X01==null){X01=document.getElementById(X00);} if(X01==null){X01=document.getElementsByName(X00);} } else { X01=document[X00]; if(X01==null){X01=document.getElementById(X00);} if(X01==null){X01=document.getElementsByName(X00);} } } } return X01; }

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups