iframe

get parent.location.url - iframe - from child to parent

只愿长相守 提交于 2019-12-17 07:17:25
问题 I got a page that is displayed within an iframe. I need to get the parent.location.url with js from that page (child page). Both sites are in different domains. I'm trying: alert(parent.location.url) But I get this error: Permission denied for http://parentdomain to get property Location.URL from http://childdomain. ???? Is it possible? 回答1: try this: var referrer = document.referrer; alert(referrer); 回答2: What you're trying to do isn't possible per se. Unless you have control over the parent

Uncaught DOMException: Blocked a frame with origin “http://localhost:8080” from accessing a cross-origin frame while listing the iframes in page

梦想的初衷 提交于 2019-12-17 06:51:53
问题 I am trying to list the names of all the iframe s in a page, so I can access them through Selenium. The problem is that the name of the iframe changes each time, so I need to loop through all of them. I am getting: Uncaught DOMException: Blocked a frame with origin "http://localhost:8080" from accessing a cross-origin frame. error when I try to loop over them using: for (var f = 0; f < window.frames.length; f++) { console.log(window.frames[f].name) } Is there a way to get the name of the

How to set HTML content into an iframe

时光总嘲笑我的痴心妄想 提交于 2019-12-17 06:36:29
问题 I have a HTML string <html> <body>Hello world</body> </html> and I want to set it to an iframe with JavaScript. I am trying to set the HTML like this: contentWindow.document.body.innerHTML or contentDocument.body.innerHTML or document.body.innerHTML but IE gives "Access is denied." or "Object does not support this property or method." or "Invalid final element to the action." errors. Here is my full code: <!DOCTYPE html> <html> <head> <script type="text/javascript" src="jquery_1.7.0.min.js"/>

How can I access the DOM elements within an iFrame

淺唱寂寞╮ 提交于 2019-12-17 06:06:25
问题 I am writing a jQuery Plugin that needs to be able to run against DOM elements within an iFrame. I'm just testing this locally right now (ie url is file://.../example.html) and in Chrome I keep hitting "SecurityError: Failed to read the 'contentDocument' property from 'HTMLIFrameElement': Blocked a frame with origin "null" from accessing a cross-origin frame." and in Safari I just get an empty document. Given that both the parent file and the iFrame's file are coming off my local disk (in

How do I load an url in iframe with Jquery

不羁的心 提交于 2019-12-17 05:40:52
问题 I want to load an iframe on click, this is what I have so far: $("#frame").click(function () { $('this').load("http://www.google.com/"); }); It doesn't work. This is the complete code: JS Bin 回答1: $("#button").click(function () { $("#frame").attr("src", "http://www.example.com/"); }); HTML: <div id="mydiv"> <iframe id="frame" src="" width="100%" height="300"> </iframe> </div> <button id="button">Load</button> 回答2: Try $(this).load("/file_name.html"); . This method targets a local file. You

Stop embedded youtube iframe?

↘锁芯ラ 提交于 2019-12-17 05:01:44
问题 I'm using YouTube iframe to embed videos on my site. <iframe width="100%" height="443" class="yvideo" id="p1QgNF6J1h0" src="http://www.youtube.com/embed/p1QgNF6J1h0?rel=0&controls=0&hd=1&showinfo=0&enablejsapi=1" frameborder="0" allowfullscreen> </iframe> And i have multiplie videos on the same page. I want to stop all of them or one of them in a click of a button using javascript or so. Is it possible? UPDATE: I tried what Talvi Watia said and used: $('#myStopClickButton').click(function(){

HTML5 iFrame Seamless Attribute

不问归期 提交于 2019-12-17 04:54:11
问题 in HTML5 the iframe has new attributes like 'seamless' that should remove borders and scrollbars. I've tried it but doesn't seem to work, I still can see scrollbars and borders (I'm using Google Chrome as browser), Here's my code: <iframe seamless="seamless" title="google" width="600" height="300" src="http://www.google.co.uk"></iframe> Any idea why it's not working? One more question, is it possible to target a specific section of the page inside the iframe? 回答1: It's not supported correctly

How does Facebook set cross-domain cookies for iFrames on canvas pages?

喜你入骨 提交于 2019-12-17 04:39:34
问题 I was browsing Facebook's documentation reading about canvas applications and I came across an example application: http://developers.facebook.com/docs/samples/canvas. As I read through their example, however, I got very confused about their use of cookies in the iframe application. A little backstory... I had already played around with using iframes for embeddable widgets (unrelated to Facebook) and I found out a few browsers (Chrome, Safari, etc.) have strict cookie policies and don't allow

Pass value to iframe from a window

…衆ロ難τιáo~ 提交于 2019-12-17 03:53:11
问题 I need to send a value to an iframe. The iframe is present within the current window. How can I achieve this? I need to do it with javascript in the parent window that contains the iframe. 回答1: First, you need to understand that you have two documents: The frame and the container (which contains the frame). The main obstacle with manipulating the frame from the container is that the frame loads asynchronously. You can't simply access it any time, you must know when it has finished loading. So

iframe自适应高度

心已入冬 提交于 2019-12-17 03:31:48
iframe,尤其是不带边框的iframe因为能和网页无缝的结合从而不刷新页面的情况下更新页面的部分数据成为可能,可是iframe的大小却不像层那样可以“伸缩自如”,所以带来了使用上的麻烦,给iframe 设置高度的时候多了也不好,少了更是不行,现在,让我来告诉大家一种iframe动态调整高度的方法,主要是以下JS函数: 程序代码 function SetWinHeight(obj) { var win=obj; if (document.getElementById) { if (win && !window.opera) { if (win.contentDocument && win.contentDocument.body.offsetHeight) win.height = win.contentDocument.body.offsetHeight; else if(win.Document && win.Document.body.scrollHeight) win.height = win.Document.body.scrollHeight; } } } 最后,加入iframe,不能丢掉onload属性,当然了,id也必须也函数中的win匹配 程序代码 <iframe width="778" align="center" height="200" id="win"