I Frame code to replace "name" attribute
-
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
-
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
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; }