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

Saturday, April 16, 2022

[FIXED] how to resolve iframe cross domain issue

 April 16, 2022     cross-domain, html, iframe, javascript, jquery     No comments   

Issue

I'm making web page that has to show another domain's web page.

For example, in my web html, there are two <div> tags.

Like :

<html>
<head></head>
<body>
   <div>
      <p> hello world </p>
   </div>
   <div>
      <!-- other domain's web page comes here -->
   </div> 
</body>
</html>

To resolve my issue, I should use <iframe>, <embed> or <object> tags, but this causes the cross domain problem. So, I can't use it to show other domain's web page. They doesn't allow me to use it.

So, for example :

<iframe src="http://stackoverflow.com"></iframe>

It doesn't work. My web page can't show stackoverflow.com. Because, stackoverflow denies this.

I have searched lots of things with these issues. But they are just ajax or JSONP. It was not iframe.

Are there solutions to resolve my problem?? Or is it impossible to implement this?


Solution

You need control over the domain you want to embed to remove/amend its CORS policy.
If the domain has explicitly blocked Cross-Origin requests, there's nothing you can do about it.

This is used to avoid anyone hijacking any site you want (you could have a full screen Google in an iframe running with your ads on top on bettergoogle.com, things like that).

This page will give you more insights on Cross-Origin



Answered By - xShirase
Answer Checked By - Robin (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

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