www.webdeveloper.com
Results 1 to 4 of 4

Thread: Targeting iframe with Javascript

  1. #1
    Join Date
    May 2010
    Location
    Johannesburg, South Africa
    Posts
    13

    Targeting iframe with Javascript

    Please help.
    I want to display search results in my iframe and I seem to have tough time with JS.

    My script is:

    onClick="CSAction(new Array(/*CMP*/'B6B2DDC23'));return CSClickReturn()"> <img src="images/New Web/search-OFF.jpg" alt="" name="fpAnimswapImgFP2" border="0" lowsrc="images/New%20Web/search-ON.jpg" id="fpAnimswapImgFP2" dynamicanimation="fpAnimswapImgFP2"></a></csobj></td>
    </form>


    My iframe name is “iframe”


  2. #2
    Join Date
    Feb 2010
    Posts
    184
    A prototype may help:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    	.iframe {
    		width: 100px;
    		height: 100px;
    		border: 1px solid #000000;
    		display: block;
    		margin: 10px;
    	}
    </style>
    <script type="text/javascript">
    	function show() {
    		var iframe = document.getElementById("iframe");
    		var input = document.getElementById("input");
    		
    		iframe.contentWindow.document.body.innerHTML = input.value;
    	}
    </script>
    </head>
    
    <body>
    <input type="text" id="input" /> <input type="button" value="Show in iframe" onclick="show()" />
    
    <iframe id="iframe" class="iframe">
    </iframe>
    </body>
    </html>

  3. #3
    Join Date
    May 2010
    Location
    Johannesburg, South Africa
    Posts
    13
    Hi there, well it is still confusing because the site was done by someone and I took-over.

    To mention the header code:


    <script language="JavaScript">
    <!--

    <!--
    function Submit() {
    document.searchpage.action = "Catelogue_nw.asp?ptype=2 " ;
    document.searchpage.submit() ;

    }

    function MM_jumpMenu(targ,selObj,restore){ //v3.0
    eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
    if (restore) selObj.selectedIndex=0;
    }

    // -->//-->
    </script>
    <csactions>
    <csaction name="B6B2DDC23" class="Call Function" type="ONEVENT" val0="Submit" val1='onClick="javascript:Submit();"'>
    </csactions>
    <csscriptdict>
    <script><!--
    CSStopExecution = false;
    CSInit = new Array;
    function CSScriptInit() {
    idxArray = new Array;
    for(var i=0;i<CSInit.length;i++)
    idxArray[i] = i;
    CSAction2(CSInit, idxArray);
    }
    function CSClickReturn () {
    var bAgent = window.navigator.userAgent;
    var bAppName = window.navigator.appName;
    if ((bAppName.indexOf("Explorer") >= 0) && (bAgent.indexOf("Mozilla/3") >= 0) && (bAgent.indexOf("Mac") >= 0))
    return true; // dont follow link
    else return false; // dont follow link
    }
    CSAg = window.navigator.userAgent; CSBVers = parseInt(CSAg.charAt(CSAg.indexOf("/")+1),10);
    function IsIE() { return CSAg.indexOf("MSIE") > 0;}
    function CSIEStyl(s) { return document.all.tags("div")[s].style; }
    function CSNSStyl(s) { return CSFindElement(s,0); }
    function CSFindElement(n,ly) { if (CSBVers < 4) return document[n];
    var curDoc = ly ? ly.document : document; var elem = curDoc[n];
    if (!elem) { for (var i=0;i<curDoc.layers.length;i++) {
    elem = CSFindElement(n,curDoc.layers[i]); if (elem) return elem; }}
    return elem;
    }
    CSIm = new Object();
    function CSIShow(n,i) {
    if (document.images) {
    if (CSIm[n]) {
    var img = (!IsIE()) ? CSFindElement(n,0) : document[n];
    if (img && typeof(CSIm[n][i].src) != "undefined") {img.src = CSIm[n][i].src;}
    if(i != 0)
    self.status = CSIm[n][3];
    else
    self.status = " ";
    return true;
    }
    }
    return false;
    }
    function CSILoad(action) {
    im = action[1];
    if (document.images) {
    CSIm[im] = new Object();
    for (var i=2;i<5;i++) {
    if (action[i] != '') { CSIm[im][i-2] = new Image(); CSIm[im][i-2].src = action[i]; }
    else CSIm[im][i-2] = 0;
    }
    CSIm[im][3] = action[5];
    }
    }
    CSStopExecution = false;

    function CSAction(array) {
    return CSAction2(CSAct, array);
    }
    function CSAction2(fct, array) {
    var result;
    for (var i=0;i<array.length;i++) {
    if(CSStopExecution) return false;
    var actArray = fct[array[i]];
    var tempArray = new Array;
    for(var j=1;j<actArray.length;j++) {
    if((actArray[j] != null) && (typeof(actArray[j]) == "object") && (actArray[j].length == 2)) {
    if(actArray[j][0] == "VAR") {
    tempArray[j] = CSStateArray[actArray[j][1]];
    }
    else {
    if(actArray[j][0] == "ACT") {
    tempArray[j] = CSAction(new Array(new String(actArray[j][1])));
    }
    else
    tempArray[j] = actArray[j];
    }
    }
    else
    tempArray[j] = actArray[j];
    }
    result = actArray[0](tempArray);
    }
    return result;
    }
    CSAct = new Object;
    function CSCallFunction(action)
    {
    var str = action[1];
    str += "(";
    str += action[2];
    str += ");"

    return eval(str);
    }
    // --></script>
    </csscriptdict>
    <csactiondict>

    <script>
    <!--
    <!--
    CSInit[CSInit.length] = new Array(CSILoad,/*CMP*/'search',/*URL*/'images/New&#37;20Web/search-OFF.jpg"',/*URL*/'images/New%20Web/search-ON.jpg',/*URL*/'','');
    CSAct[/*CMP*/ 'B6B2DDC23'] = new Array(CSCallFunction,'Submit','onClick=\"javascript:Submit();\"');

    // -->

    function MM_swapImgRestore() { //v3.0
    var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
    }

    function MM_preloadImages() { //v3.0
    var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    }

    function MM_findObj(n, d) { //v4.0
    var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
    if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
    if(!x && document.getElementById) x=document.getElementById(n); return x;
    }

    function MM_swapImage() { //v3.0
    var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
    if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
    }
    //-->
    </script>
    </csactiondict>
    <style type="text/css"><!--
    #layer1 { position: absolute; z-index: 1; top: 2px; left: 473px; width: 90px; height: 20px; visibility: visible }
    .darkbloo { color: #ffffff; font-style: italic; font-size: 10pt; font-family: Verdana, Arial, Helvetica, sans-serif; text-decoration: none; background: #6666cc no-repeat; border-style: inset; border-width: 1px; border-color: #cccccc black black black }-->
    </style>
    <base target="Body1">
    <script language="JavaScript" fptype="dynamicanimation">
    <!--
    function dynAnimation() {}
    function clickSwapImg() {}
    //-->
    </script>
    <script language="JavaScript1.2" fptype="dynamicanimation" src="animate.js">
    </script>

  4. #4
    Join Date
    May 2010
    Location
    Johannesburg, South Africa
    Posts
    13
    Hey guys, at last i've managed to sort it by inserting this code before </heard> tag

    <base target="iframe">

    Thanks for your input.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles