Cross domain iframe issue

前端 未结 5 1727
[愿得一人]
[愿得一人] 2020-11-21 06:14

For say i have a Site called example.com on which iframe is embedded of domain iframe.net, now i want to read the content of iframe and pass some parameter to display a text

5条回答
  •  再見小時候
    2020-11-21 06:44

    iFrame does not allow to access contents from Cross Domain platform. You can only access if your iFrame is using the same domain.

    This solution works same as iFrame. I have created a PHP script that can get all the contents from the other website, and most important part is you can easily apply your custom jQuery to that external content. Please refer to the following script that can get all the contents from the other website and then you can apply your cusom jQuery/JS as well. This content can be used anywhere, inside any element or any page.

    /* Here I am writing a sample jQuery to hide the navigation menu You can write your own jQuery for this content */ //Hide Navigation bar jQuery(\".navbar.navbar-default\").hide(); "; //Append Custom JS with HTML $html = $content . $customJS; //Return customized HTML return $html; }

提交回复
热议问题