PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, April 15, 2022

[FIXED] How to open JavaScript link into iframe in parent

 April 15, 2022     dom-events, iframe, javascript     No comments   

Issue

I am trying to call dynamically created link in JavaScript into iframe. Dynamic links are being created but links are opening in parent window instead of iframe.

    <li><a href="#">New Member Name</a>
  <ul>
    <li><script type="text/javascript">
<!--
var d = new Date()

month=(d.getUTCMonth()+1).toString();
if(month.length<2) month = "0" + month;

day=(d.getUTCDate()).toString();
if(day.length<2) day = "0" + day;

hour=(d.getUTCHours()).toString();
if(hour.length<2) hour = "0" + hour;

minute=(d.getUTCMinutes()).toString();
if(minute.length<2) minute = "0" + minute;

for (x=1 ; x<=10 ; x++)
{
    xx = x.toString();  
    if (xx.length<2) xx = "0" + xx;

    h= "http://apps.facebook.com/evonyoffical/facebook.Uprising.php?F=100002319241135&C=878988&SID=NA46&T=" + d.getUTCFullYear() + "." + month + "." + day + "+" + hour + "." + minute + "." + xx + "&SX=0&FEEDID=10001&GUID=220B83CD-91F8-D26A-B411-25BC9BAF1B5E&k=070d6091c63e5a21b5a1e9b829262396"; target="_rightfb"
    document.writeln("<p>"+("Link "+x).link(h)+"</p>");
}
//-->
</script></li>
  </ul>
</li>   

Where the iframe div properties are:

<div id=facebook><iframe src='javascript:""' name="rightfb"  width:"900" height:"450"></iframe></div>

Solution

I would create the link to write to the src of the iframe. The following produces links that load the url into the iframe however when I tried it I got a response that the website will not allow content to be written to a frame for security reasons (maybe because I was just opening the html file from the file system and not through a server).

url= "http://apps.facebook.com/evonyoffical/facebook.Uprising.php?F=100002319241135&C=878988&SID=NA46&T=" + d.getUTCFullYear() + "." + month + "." + day + "+" + hour + "." + minute + "." + xx + "&SX=0&FEEDID=10001&GUID=220B83CD-91F8-D26A-B411-25BC9BAF1B5E&k=070d6091c63e5a21b5a1e9b829262396";
html='<p><a onClick="document.getElementById(\'rightfb\').src=\'' + url + '\'" style="color:blue;cursor:pointer">Link' + x + '</a></p>';
document.write(html);


Answered By - ElPedro
Answer Checked By - David Goodson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing