for example, my own website www.aaa.com, uses iframe to introduce www.bb.com (other people"s websites, which I can"t control).
can you get this?
for example, my own website www.aaa.com, uses iframe to introduce www.bb.com (other people"s websites, which I can"t control).
can you get this?
homologous policy cannot be realized at the front end. If you can manipulate the elements of a child page casually, it will be very dangerous for the pages in iframe
.
if you really want to manipulate the elements in iframe
, try using the nginx
agent to implement
method one
write your page configuration and proxy forwarding configuration in a server
, distinguish between different location
, so that their domain names are the same, and there is no cross-domain problem. In this way, if you want to adjust the access path of the static problem of the proxy page, the example will not give
method two
write two server
and server1
assuming the domain name is aaa.xxx.com
and act as a proxy. When returning, insert a js code to modify domain=xxx.com
, server2
assume the domain name is bbb.xxx.com
, use it as your page, and set domain=xxx.com
in front of the page.
here's an example: aaa.xxx.com
Agent www.qq.com
, bbb.xxx.com
iframe
reference aaa.xxx.com
, and get the element
iframe
first is server
configuration
nginx
server {
listen 80;
server_name aaa.xxx.com;
location / {
proxy_pass https://www.qq.com/;
proxy_set_header Host www.qq.com;
proxy_set_header X-Forwarded-For $remote_addr;
-sharp (:)
proxy_set_header Accept-Encoding '';
-sharp JS --with-http_sub_module
sub_filter '</head>' '</head><script>document.domain = \'xxx.com\';</script>';
sub_filter_once off;
}
}
server {
listen 80;
server_name bbb.xxx.com;
root /home/www/bbb.xxx.com;
location / {
}
}
then write a test code / home/www/bbb.xxx.com/index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<iframe style="width: 100%;height: 100%" id="iframe" src="http://aaa.xxx.com"></iframe>
</body>
<script>
document.domain = 'xxx.com';
var iframe = document.getElementById('iframe');
iframe.onload = function(){
// iframe id sosobar
console.log('iframe', iframe.contentWindow.document.getElementById('sosobar'));
}
</script>
</html>
start Nginx
, visit bbb.xxx.com
to view the results
as you can see, iframe
has achieved cross-domain implementation, but in doing so, some problems cannot be ignored
https
question JS
, CSS
, png
loaded through independent domain names, may have cross-domain or permission problems domain
so that some resources cannot be obtained ps:, if you have a good solution, you are welcome to share
how can the data looped out by vue change color to the current one when clicked? this is what my page says <ol v-if="tooglezhi" class="ol_one"> <li v-for="(item,key) in arr" ...
the number of digits in the input box is controlled. When this value echoes the maximum number of digits, the input can only be deleted and the input cannot be overridden directly. who knows what attributes the input has to control this ...
Baidu didn t find the reason for it for a while-the error message thrown by the browser was Uncaught Error: Objects are not valid as a React child (found: object with keys {}). If you meant to render a collection of children, use an array instead or wr...
shouldn t vue use vue-router? Why can it only be put into devDependencies (development dependency)? ...
I used Wechat developer tool to debug the official account of the web page, but suddenly the page did not display, there was nothing in div-sharpapp, there were all those routes, and other colleagues could run this project, but I couldn t. It was a blan...
...
the demand is like this, the left menu bar, the right content area, click a button to load an iframe page, click the next to load another iframe page, how to achieve? I don t know much about iframe pages, thank you! ...
<image>< image>< svg> <script> const aa = document.getElementById( aa ) const bb = document.createElement( svg ) bb.innerHTML = aa.innerHTML bb"<img>""<image>< imag...
1. Today, when I maintained the old code of the company, I saw some of the old code. The purpose of this code is to load the html template. index.htmljs $( div ).load( templateOfchart.html ); templateOfchart.html content in 2.templateOfchar...
as shown in figure I really can t find it. Ask for help ...
$this.printAsset = function () { var selectedIds = selectedAssetIds(); if (selectedIds.length == 0) { bootAlert( ); return false; } window.location.href = Asset Print?ids= + selectedAssetIds(); }; A snippet of c...
I d like to ask the bosses that if you want to use hbuilder to develop hybrid app, that has written ajax requests, you can request the obtained data in the local server environment. But after packaging, if you test it on the phone, you can t get the da...
if the div from v-for in vue shows that div1 has a div3, condition, it first shows that div3, will be squeezed out of div3 when the next condition is set up for div1 display. How to solve this problem? the code for my loop is <div class=&q...
<a href="xx">< a> ...
how does 1.ECharts increase the chart according to the data? for example, if I have two pieces of data here, how can I add two gauges? 2. This is the code, you need to use c3text and c4text to set the scale of the dashboard: ] [1] 3. This is the cod...
after my page loads, there will be a sort number. when I double-click the current row, the sort number will become editable and will be saved after losing focus. what do I do? I can get the id, of the current line, but how to edit the current line....
base64: var str_base64 = "CgkJCgkJCQk8Y29uZGl0aW9ucyB0eXBlPSJBTkQiPgoJCQkJCTxzeXNDb25kaXRpb25zIHR5cGU9Inx8Ij4KCQkJCQk8c3lzQ29uZGl0aW9uIG5hbWU9ItDCzsS1tSIgZXhwcmVzc2lvbj0iS0dselRtVjNSRzlqS0NrcElBPT0iLz4KCQkJCQk8c3lzQ29uZGl0aW9uIG5hbWU9IrWxx7C0psDtyMs...
I created a table table, and the expected effect is that when the mouse moves over each table cell th, the background color automatically turns white and an audio is played. The problem with now is that the background color of the cell has been success...
exif.js:380 XMLHttpRequest cannot load file: C: Users pjy Desktop exif-js exif-js-master example dsc_09827.jpg. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https. ...
when the first picture is normal, then click on the left column to put away the rotation picture can not immediately adapt to the screen to appear a blank the strangest thing is that as soon as I press F12 to view the elements, it can be self-adap...