Hello ,
On trying to open a webpage in an ‘iframe’ , many sites give an error msg “refused to connect” .
Could that be avoided by using a software webserver , something like TinyWeb ?
Thanks
Hello ,
On trying to open a webpage in an ‘iframe’ , many sites give an error msg “refused to connect” .
Could that be avoided by using a software webserver , something like TinyWeb ?
Thanks
I think you’ll have to post up some more info on how you’re using it. The code you have would be really useful to see. I’m also curious as to why you’re posting a question about <iframe>
( an HTML element) here in the JavaScript channel.
Oops , Pls , anyone feel free to move it .
I have been immersed in js lately .
Thanks
I think some sites don’t want to be put in an iframe, and will block referrers that try it.
Yes , I understand why they do it .
I am asking if making a ‘webpage request’ thru a win 10 server is a way to circumvent that rejection ?
Thanks
I’m not sure how that would help.
If a site blocks iframe embeds, the owner does not want iframe embeds of their site.
Filtered thru server how would they know ?
Well, what site are you trying to put into an iframe?
m_hutley ,
Same Domain:
file:///C:/Users/me/Downloads/SomeLocalLinks-01.html
file:///C:/Users/me/Downloads/WIP-Parent.html
Source is here:
http://vmars.us/KidSafeBrowser/WIP-Parent.html
Thanks for your Help…
That doesn’t seem to match up with what you said earlier.
That’s not… the same site. And your iframe works fine for me in your link.
Oops , my mistake , that was the local version .
Give me a some minutes ;
I’ll make up a new iframe page to show you what I mean .
Try this :
WIP-Parent.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>Opening Links in an iFrame</title>
<style>
iframe {
width: 100%;
height: 500px;
}
button {display: inline-block;}
iframe { width="50%";}
</style>
</head>
<body>
<p style="text-align: center;">Communiation Between 'parent' and 'iframe Child' elements
<button onclick="Function_1()">1</button>
<button onclick="Function_2()">2</button>
<button onclick="Function_3()">3</button>
<button onclick="Function_4()">4</button>
<p id="paragraph_1"> empty </p>
<iframe id="iFrame1" src="SomeLocalLinks-01.html" name="iFrame1"></iframe>
<script>
var links = iFrame1.document.querySelectorAll( 'a' );
for ( var c = 0; c < links.length; c ++ ) {
links[c].addEventListener('click', WhichLinkWasClicked);
}
function WhichLinkWasClicked(evt) {
alert( evt.target ) ;
evt.preventDefault();
}
</script>
<script>
function Function_1(){
console.log("Function-1()")
const iFrame1 = document.querySelector("iFrame");
console.log(iFrame1)
const iFrame1Body = iFrame1.Document.querySelector("a") ;
console.log(iFrame1Body)
/*
var iframe1DocumentBody = iFrame1.document.querySelector("body");
console.log(iframeDocumentBody)
console.log(iframe.document)
console.log(iframe.document.querySelector("a"));
console.log(iframe);
iframe = iframe.document.documentElement
console.log(iframe);
document.getElementById("paragraph_1").innerHTML = iframe ;
*/
}
</script>
<script>
function Function_2()
{
alert("Function-2()")}
</script>
<script>
function Function_3(){
alert("Function-3()")}
</script>
<script>
function Function_4(){
alert("Function-4()")}
</script>
</body></html>
SomeLocalLinks-01.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>Opening Links from an iFrame</title>
<style>
iframe {
width: 100%;
height: 500px;
}
</style>
</head>
<body>
<h1 style="text-align: center">Not local sites </h1>
<br><br><a href="https://duckduckgo.com">https://duckduckgo.com</a>
<br><br><a href="https:/google.com">https:/google.com</a>
<br><br><a href="https://www.kidzsearch.com">No Problem</a>
<br><br><a href="http://www.peepandthebigwideworld.com">http://www.peepandthebigwideworld.com</a>
<br><br></body></html>
I think that’s all in order .
So the duckduckgo link response contains the header:
x-frame-options:SAMEORIGIN
which is telling your browser not to render it in the page because your iframe isn’t on duckduckgo.com
.
They do allow iframing on their search box: https://duckduckgo.com/search_box
So clearly the site has taken a stance on what is acceptable usage of their content.
Similarly, Google makes certain pages available to be iframed, but their main site is not one of them.
As these sites have expressly declared their intention not to allow iframing of their website, the only stance I can take is that that’s the way it is. To do otherwise would be a violation of their terms of use.
Ugh!
I thought I could first download the page , on my disc , with python , then load the page from there . Then if I open with chrome , it takes minutes to fully load ,
and of course any embeded frames are blank except for a message “It may have been moved edited or deleted” .
I even did a Chrome download via ‘more tools & save as’ to Downloads area ,
when I opened that version of the downloaded page in my iframe , it did flash for a second . But then disappeared . I even went so far as to remove the ‘meta’ Tags from the incoming Chrome page , but still , no go .
Ugh!
Thanks
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.