iframe

WEB 前端跨域解决方案

旧巷老猫 提交于 2020-01-04 03:19:19
跨域定义 广义的定义:跨域是指一个域下的文档或脚本试图去请求另一个域下的资源。 1.) 资源跳转: 链接、重定向、表单提交 2.) 资源嵌入: <link>、<script>、<img>、<frame>等dom标签,还有样式中background:url()、@font-face()等文件外链 3.) 脚本请求: js发起的ajax请求、dom和js对象的跨域操作等 同源策略 同源策略/SOP(Same origin policy)是一种约定,由Netscape公司1995年引入浏览器,它是浏览器最核心也最基本的安全功能,如果缺少了同源策略,浏览器很容易受到XSS、CSFR等攻击。所谓同源是指"协议+域名+端口"三者相同,即便两个不同的域名指向同一个ip地址,也非同源。 同源策略限制以下几种行为: 1.) Cookie、LocalStorage 和 IndexDB 无法读取 2.) DOM 和 Js对象无法获得 3.) AJAX 请求不能发送 跨域解决方案 1)jsonp跨域 关于jsonp的原理把握一下几点: 1)html标签的src属性没有同源限制(支持跨域),浏览器解析script标签时,会自动下载src属性值(url)指向的资源; 2)script标签指向的资源文件被下载后,其中的内容会被立即执行; 3)服务器端的程序会解析src属性值中的url传递的参数

YouTube embed iframe not showing in Safari

依然范特西╮ 提交于 2020-01-04 02:51:07
问题 The link is http://thecodeclub.org/ and there is a YouTube video. Works fine in Chrome but the iframe remains blank in Safari? Has anyone else encountered this or have a fix? <div class="wrapper wrapper-style2"> <article id="work"> <header> <h2>What Most Schools Don't Teach</h2> <p>Even rap stars are learning to code...</p> </header> <div class="video-container"> <iframe width="560" height="315" src="https://www.youtube.com/embed/nKIu9yen5nc?rel=0" frameborder="0" allowfullscreen></iframe> <

This page contains both secure and nonsecure items and iframes

本秂侑毒 提交于 2020-01-04 02:29:14
问题 IE 6.0 is giving me the message "This page contains both secure and nonsecure items" because I have iframes on my page (for the combo box bug). I have tried pointing to a few different things in the src but I can't seem to get rid of this message without putting in a blank html page, which I would like to avoid so there isn't a server call. Is there any solution? I suppose I could use the blank page and have the cache never expire on it possibly if there is no other choice and that should

从父页面在iframe中调用JavaScript代码

别说谁变了你拦得住时间么 提交于 2020-01-04 01:49:52
基本上,我将 iframe 嵌入到页面中,并且 iframe 具有一些我需要从父页面调用的 JavaScript 例程。 现在相反非常简单,因为您只需要调用 parent.functionName() ,但是不幸的是,我需要恰好相反。 请注意,我的问题不是更改 iframe 的源 URL ,而是调用 iframe 定义的函数。 #1楼 仅作记录,我今天遇到了同一问题,但是这次页面被嵌入对象而不是iframe中(因为它是XHTML 1.1文档)。 这是如何与对象一起使用的: document .getElementById('targetFrame') .contentDocument .defaultView .targetFunction(); (很抱歉换行太丑,没有一行) #2楼 跟随尼丁·班萨尔(Nitin Bansal)的答案 以及更强大的功能: function getIframeWindow(iframe_object) { var doc; if (iframe_object.contentWindow) { return iframe_object.contentWindow; } if (iframe_object.window) { return iframe_object.window; } if (!doc && iframe_object

Using relative url for window.location in child iframe

假如想象 提交于 2020-01-03 19:34:13
问题 I'm having trouble with an iframe-related issue. I have a document (parent) with an iframe (child). If the parent document calls a function in the child which changes the childs url using window.location to a relative url, that url becomes relative to the parent document. Let me illustrate. Parent document: /test/parent.html Child document: /projects/child.html Child code: function moveOn(){ window.location.href = "newPage.html"; } Parent code: childDocument.contentWindow.moveOn(); Result:

How can i get the hash value from an iframe src?

我与影子孤独终老i 提交于 2020-01-03 17:13:12
问题 My iframe is having a url with a hash value when i do iframe.src it just gives me the url without the hash appended to it from the other domain. Can i read the entire url with the hash. 回答1: Not likely due to security constraints - I am surprised you can even get the URL Can you show the code? Sounds like a duplicate of How to get iframe contentWindow height in cross domain 回答2: var contentWnd = $('iframe').attr('contentWindow'); var hash = contentWnd.window.location.hash; Adaptation of this

jQuery file upload plugin - fail callback not firing in IE < 10

会有一股神秘感。 提交于 2020-01-03 17:06:53
问题 I am using the https://github.com/blueimp/jQuery-File-Upload It uses XHR file uploads in modern browser and hidden iframe uploads in oldIEs (8,9). The server returns a 4xx status code (error/fail), when file validation failed. $('#fileupload').fileupload({ url: url, dataType: 'json', done: function (e, data) { console.log("done") }, fail: function (e, data) { console.log("fail") } }) However in oldIEs the done callback is called even when I send a 4xx status code. Is there a way to make it

How to scroll parent page with iFrame reload

让人想犯罪 __ 提交于 2020-01-03 17:05:55
问题 I have a page with a long iframe on it, which loads a schedule display with pages of various lengths. When a new page is displayed in the iframe though, the main page is often still showing the bottom of the page (lots of whitespace). How can I have the main page scroll to the top anytime a new page is loaded in the iframe? This is the page I've tried this is jQuery (on the parent page): <script type="text/javascript"> jQuery(document).ready(function() { $('#body iframe').load(function(){ $

JavaScript - Detecting Scrollbars in a Cross-Domain Iframe?

喜欢而已 提交于 2020-01-03 16:53:17
问题 I'm loading a cross-domain page (that I have no control over) into an iframe. I want to know if this results in a scrollbar appearing in the iframe on my page or not. I'm getting the impression that this just cannot be done (in Firefox at least), through any kind of direct detection or clever deduction, due to cross-domain security policies. Please only answer this question if you have direct experience successfully doing this yourself -- or trying everything and giving up. (Those other

Print Iframe with PDF generated on the fly IE 11

南楼画角 提交于 2020-01-03 15:35:29
问题 I wanted to print a pdf which is generated on the fly in an Iframe, but can't get that print this pdf file. This is what i have now, am i doing something wrong?. Works fine on Google Chrome but not on IE 11. Please help me to get this work. Thanks in advance this is the HTML markup <div id="contractFrameContainer" class="modal-body row"> <iframe id="contractIframe" name="contractIframe" width="100%" src=""></iframe> </div> Here is my javascript where i assign the src of the iframme with the