0% found this document useful (0 votes)
22K views7 pages

Work With Frames

The document discusses several functions related to manipulating elements on a page with nested frames. It defines a CreateDynaLinkClass with methods to disable and enable hyperlinks using jQuery. It also defines functions to get form element values across frames, compare current values to initial loaded values, and set form name values in parent and grandparent frames on page load and clicks.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22K views7 pages

Work With Frames

The document discusses several functions related to manipulating elements on a page with nested frames. It defines a CreateDynaLinkClass with methods to disable and enable hyperlinks using jQuery. It also defines functions to get form element values across frames, compare current values to initial loaded values, and set form name values in parent and grandparent frames on page load and clicks.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Getting Value of all frames used at front end.

var i =new Array; function wow(a,n) { t=''; for(i[n]=0;i[n]<a.length;i[n]++) { t+=i[n]+"--"+a[i[n]].name+"\n"; if(a[i[n]].frames.length) t+=wow(a[i[n]].frames,n+1);

} return t; }

alert(wow(top.frames,0));

Creating Javascript Class and Prototype Methods (setting and removing attribute of tag using JQuery)

function CreateDynaLinkClass(){ } var CreateDynaLinkClass = new CreateDynaLinkClass(); CreateDynaLinkClass.prototype = { DisLinkMethod: function(){ $("a").removeAttr("href");

}, EnbLinkMethod: function(link){ $("a").removeAttr("href"); $("a").attr("href", document.getElementById("contextPath").value+link ); }, CommonLinkMethod: function(){ $("a").css({"cursor":"pointer"}); }

Calling function on click to get all element value of a form inside the nested frame (adding hyperlink through Jquery ) :
function callFunction(san,id){

CreateDynaLinkClass.prototype.DisLinkMethod(); var formVal = ""; if (top.frames['content'] != null){ formVal = top.frames['content'].window.frames['menu'].document.getElementById("getFormName").value; }else{ formVal = top.frames['menu'].document.getElementById("getFormName").value; } if(checkModifiedChanges(formVal,id)){ if(!confirm('Data has been changed ! Do you want to proceed... ')){ CreateDynaLinkClass.prototype.CommonLinkMethod();

return false; }else { CreateDynaLinkClass.prototype.EnbLinkMethod(san);

//top.frames['content'].window.frames['menu'].document.getElementById("getTabId").value = id;

top.frames['content'].window.frames['body'].document.getElementById(formVal).action = document.getElementById("contextPath").value+san;

top.frames['content'].window.frames['body'].document.getElementById(formVal).submit(); } }else if(document.getElementById("recStatus").value == ""){ alert(document.getElementById("dealMoveMsg").value); return false; }else { CreateDynaLinkClass.prototype.EnbLinkMethod(san); } return true; }

Getting Value of form at page load time & comparing with value that is rechecked onclick event :

function checkModifiedChanges(san,id){ var reqFields ="";

if (top.frames['content'] != null){ if(top.frames['content'].window.frames[1].document.getElementById(san) != null){ elem = top.frames['content'].window.frames[1].document.getElementById(san).elements; var prevVal = parent.menu.document.test.checkModifications.value; }else{ elem = top.frames['content'].window.frames[1].window.frames[1].document.getElementById(san).elements; var prevVal = parent.menu.document.test.checkModifications.value; } }else{ if(top.window.frames[1].document.getElementById(san) != null){ elem = top.frames[1].document.getElementById(san).elements; var prevVal = parent.menu.document.test.checkModifications.value; }else{ elem = top.frames[1].window.frames[1].document.getElementById(san).elements; var prevVal = parent.menu.document.test.checkModifications.value; } } for(var i=0; i<= elem.length;i++){

var str = ''; if(!elem[i] || elem[i] == "undefined" || elem[i].value == "undefined" || elem[i].name == (null || '')){ continue;

} if(elem[i].getAttribute('type') != 'hidden' && elem[i].getAttribute('type') != 'button'){ if(elem[i].value != null || elem[i].value != ""){ reqFields += "* "+elem[i].value; } }else continue; }

var currVal = reqFields; if(prevVal == currVal){ return false; } else return true;

Call function at body onload:

function checkChanges(formName){ var reqFields =""; elem = document.getElementById(formName).elements; for(var i=0; i<= elem.length;i++){ var str = ''; if(!elem[i] || elem[i] == "undefined" || elem[i].value == "undefined" || elem[i].name == (null || '')){ continue;

} if(elem[i].getAttribute('type') != 'hidden' && elem[i].getAttribute('type') != 'button'){

if(elem[i].value != null || elem[i].value != ""){ reqFields += "* "+elem[i].value; } }else continue; } parent.menu.document.test.checkModifications.value = reqFields; if(parent.parent.menu.document.test != null){ parent.parent.menu.document.test.checkModifications.value = reqFields; } }

Setting value to parent and parent of parent frame :

function setFramevalues(currentForm){

if(parent.parent.menu.document.test == 'undefined' || parent.parent.menu.document.test == null){ if(parent.menu.document.test == 'undefined' || parent.menu.document.test == null){

}else{ parent.menu.document.test.getFormName.value = currentForm; } }else{ parent.menu.document.test.getFormName.value = currentForm; parent.parent.menu.document.test.getFormName.value = currentForm; }

You might also like