0

I am working on adding a news section to my website and would like for the section to show the top stories from a news site. The best way to do this I found would be with an IFrame (not sure if this is best way to do what I am wanting to do). I have created the script to make the IFrame show what I am wanting it to show, but the news story gets opened within the border created. I am wanting to make it so that if they click the news story they go to the article directly, or make it so that if it is clicked the article is opened bigger on the main site, so that it can actually be read.

This is the script I am currently working with.

KKTV TOP HEADLINES

<iframe src="https://www.kktv.com" style="border: 0px none; margin-left: 2px; height: 960px; margin-top: -520px; width: 800px;">

Any help with figuring out how to accomplish my goal or other ideas to create what I am wanting to create is greatly appreciated. My main goal is to create a block for my website that shows this news websites top stories that people can then click on and read (either on my website or redirected directly to the articles site).

DonaldV
  • 1
  • 1

2 Answers2

-1

This question should contain your answer.

"You can't (or it is extremely hard to ) make events inside the iframe affect the parent page. This is to prevent attacks from XSS, or cross site scripting. Having said that, if the site within the iframe is on your own domain and you want to set up some extremely tricky ajaxing and php session IDs, maybe you could make something work, but even then I'm not sure. And I don't know if this would be a security hole, maybe someone else can speak to that. It would perhaps look like:

  1. main page sets up session ID and passes that to the iframe url via a get variable

  2. the iframe takes click information and sends it to a Session variable via an ajaxing call to a script on the server.

  3. The main page then reads (how?) the session cookie and makes changes based on it's value.

All in all, you may find that it may be much simpler and more secure to achieve what you want using a different method."

  • How do you expect this to work? OP has no control over the site inside the iframe. And if the answer is a copy paste from another question, then it should probably be closed as a duplicate. – gre_gor Jan 04 '22 at 03:33
-1

it open the url as pop-up but google chrome block it ... good luck on what you're doing i guess

 <script> window.open("https://www.kktv.com","_blank"); </script>
Emma Marshall
  • 354
  • 1
  • 12
  • OP wants to open links inside the iframe in a new tab, not the iframe link itself inside a new window. – gre_gor Jan 04 '22 at 03:34