iframe

iframe标签刷新页面停留在当前页

此生再无相见时 提交于 2020-02-29 02:11:36
整体思路:在iframe所在当前页面地址url后拼接 #+targetUrl <a href="url" target="iframeId" onclick="loadIframe($(this))">a标签跳转iframe</a> // iframe模板刷新后页面跳转问题解决--start function loadIframe(url) { //获取url链接 var u = window.location.href; //因为每次获取的链接中都有之前的旧锚点, //所以需要把#之后的旧锚点去掉再来加新的锚点(即传入的url参数) var end = u.indexOf("#"); var rurl = u.substring(0,end); if(rurl == ''){ rurl="当前页面url" } //设置新的锚点 window.location.href = rurl + "#" + url; } window.onhashchange = function() { //location.hash取到的是url链接中#(包括自己)后面的内容 var hash = location.hash; //去掉#号,得到的就是我们要设置到iframe中src上的地址 var url = hash.substring(1,hash.length); $("#iframeId")

iframe 跨域访问session/cookie丢失问题解决方法

戏子无情 提交于 2020-02-28 12:58:39
今天因工作需要,在一个域名A的页面中,使用iframe包含另一个域名B的页面。在chrome,firefox测试一切正常。 当测试到IE7时,发现域名B中的页面session失效,不能写入session。 网上搜索后了解, 因为IE有安全策略,限制页面不保存第三方cookie(当前访问域名A下的页面为第一方cookie,而域名B下的页面为第三方cookie)。 虽然有安全策略限制,但我们可以引入 P3P 声明允许第三方收集个人信息,使第三方cookie不被拒绝。 P3P:Platform for Privacy Preferences (隐私偏好平台)是W3C公布的一项隐私保护推荐标准,能够保护在线隐私权。使用Internet者可以选择在浏览网页时,是否被第三方收集并利用自己的个人信息。如果一个站点不遵守P3P标准,它的Cookies将被自动拒绝。 在iframe的页面头加入以下语句即可解决session失效问题。 [php] view plain copy header( 'P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"' ); a.com/index.php [html] view plain copy <!DOCTYPE HTML PUBLIC

详解Html5页面实现下载文件(apk、txt等)的三种方式

荒凉一梦 提交于 2020-02-27 23:07:11
这篇文章主要介绍了详解Html5页面实现下载文件(apk、txt等)的三种方式,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧 需求描述 接到的原始需求是这样的,有一个H5页面,页面中有个“点击下载”的按钮,点击之后,完成下载特定的apk。 大概是下面这样的👇: 需求分析 接到需求的时候我偷乐了一下,这个H5页面最大的优点是不在微信中使用(微信好坑,各种限制,基本上从微信浏览器里面实现直接下载apk是不太可能的),如果是在平常的浏览器的话,就简单多了。 功能实现 于是我想到了第一种,点击下载按钮的时候改变location.href。 方法一: ? 1 2 // 我随便找了个apk的下载链接举个例子 window.location.href = ' http://imtt.dd.qq.com/16891/26747DD8B125A8479AD0C9D22CA47BC9.apk?fsname=com.snda.wifilocating_4.2.91_3211.apk&csr=1bbd ' ; 拿在浏览器里面试了下,多个安卓机型都可以走通,然后我美滋滋得交付了任务,收拾收拾东西回家。 然后………… 截图中所说的空白页是因为我改变href为apk的下载链接,网页打开的时候会停留在一个空白页,然后一般手机的状态栏上会出现下载apk的进度条。

Cookie已阻止/未保存在Internet Explorer的IFRAME中

别来无恙 提交于 2020-02-27 08:26:25
我有两个网站,假设他们是 example.com 和 anotherexample.net 。 在 anotherexample.net/page.html ,我有一个 IFRAME SRC="http://example.com/someform.asp" 。 IFRAME显示一个表单供用户填写并提交到 http://example.com/process.asp 。 当我在自己的浏览器窗口中打开表单(“ someform.asp ”)时,一切正常。 但是, 当我在IE 6或IE 7 someform.asp 加载为IFRAME时,example.com的cookie不会保存。 在Firefox中,此问题不会出现。 出于测试目的,我在 http://newmoon.wz.cz/test/page.php 上创建了类似的设置。 example.com 使用基于cookie的会话(我无能为力),所以没有cookie, process.asp 将不会执行。 如何强制IE保存这些cookie? 嗅探HTTP流量的结果:在GET /someform.asp响应中,有一个有效的每会话Set-Cookie头(例如 Set-Cookie: ASPKSJIUIUGF=JKHJUHVGFYTTYFY ),但在POST /process.asp请求中,没有Cookie头一点都不 Edit3

H5与Native交互之JSBridge技术

谁说胖子不能爱 提交于 2020-02-27 06:17:55
一、原理篇 下面分别介绍IOS和Android与Javascript的底层交互原理 IOS 在讲解原理之前,首先来了解下iOS的UIWebView组件,先来看一下苹果官方的介绍: You can use the UIWebView class to embed web content in your application. To do so, you simply create a UIWebView object, attach it to a window, and send it a request to load web content. You can also use this class to move back and forward in the history of webpages, and you can even set some web content properties programmatically. 上面的意思是说UIWebView是一个可加载网页的对象,它有浏览记录功能,且对加载的网页内容是可编程的。说白了UIWebView有类似浏览器的功能,我们使用可以它来打开页面,并做一些定制化的功能,如可以让js调某个方法可以取到手机的GPS信息。 但需要注意的是,Safari浏览器使用的浏览器控件和UIwebView组件并不是同一个

easyui获取当前选中的tabs

南笙酒味 提交于 2020-02-27 05:18:38
$("#" + $("#tabs").find("iframe")[$(".tabs-header ul li").index($('.tabs-selected')) - 1].id).contents().find(".search_button").click(); 这句代码获取easyui当前选中的tabs并触发类为".search_button"的点击事件 $("#tabs").find("iframe") tabs为easyui的ID,tabs在HTML上加载的就是iframe,所以上面这句代码是获取获取当前打开的所有tabs (每打开一个tabs,HTML上就多一个iframe,同理每关闭一个tabs,HTML上就少一个iframe,动态加载) $(".tabs-header ul li").index($('.tabs-selected')) 为当前显示的tabs的index, 注:tabs在页面上显示的顺序与HTML上iframe的顺序一致,但由于有首页,所以index会比iframe序号多1,所以要减1 $("#tabs").find("iframe")[$(".tabs-header ul li").index($('.tabs-selected')) - 1] 这样就可以获取到了当前显示的tabs的iframe节点HTML 来源: https://www

Easyui Tabs 添加怎么添加。

夙愿已清 提交于 2020-02-27 05:17:37
function addPanel(url, title) { if ($("#mainTabs").tabs("exists", title)) { $("#mainTabs").tabs("select", title); //var tab = $('#mainTabs').tabs('getSelected'); // 获取选择的面板tab.panel('refresh', 'get_content.php'); //刷新当前选择页面 var current_tab = $('#mainTabs').tabs('getSelected'); $('#mainTabs').tabs('update', { tab: current_tab, options: { content: '<iframe frameborder="0" height="100%" width="100%" src="' + url + '" style="overflow:hidden" ></iframe>' } }); } else { $('#mainTabs').tabs('add', { title: title, content: '<iframe frameborder="0" height="100%" width="100%" src="' + url + '" style=

跨文档消息传递 postMessage

孤人 提交于 2020-02-27 05:09:58
一、跨文档消息传递 1. postMessage 发送信息 向当前页面的 <iframe> 元素传送数据 // 接收方window对象.postMessage( "message", "接收方域名" ); var iframeWindow = document.getElementById("myframe").contentWindow; //contentWindow iframeWindow.postMessage("a secret","http://www.wrox.com"); //向内嵌框架发送消息 接收信息 该方法触发接收方 window 对象的 message 事件,并且传递个 onmessage处理程序的 event 包括以下三方面信息 data:postMessage()第一个参数传过来的 message,最好只传字符串 (结合: JSON.stringify(), JSON.parse() ) origin: 发生消息的文档所在的域 source: 发送消息的文档的 window对象 代理 //接收到其他窗口发送过来的信息 window.addEventListener("message", function(event){ event.source.postMessage("收到",event.origin) //向原窗口发送回执 }) 2. 例子 外层

positioning content of an iframe within a containing div

妖精的绣舞 提交于 2020-02-27 03:51:23
问题 I've got a page which I need to serve via an iframe, but I need to only display part of the page, not the whole thing. My current code is: <div style="display:block;overflow:hidden;width:500px;height:350px;"> <iframe height="350px" scrolling="no" src="http://my/page/i/want/to/show/part/of/here/" width="500px"></iframe></div> I thought that the best option would be to serve the iframe within a containing div that has "overflow:hidden" so that it acts like a picture frame. That works, but the

positioning content of an iframe within a containing div

纵饮孤独 提交于 2020-02-27 03:51:07
问题 I've got a page which I need to serve via an iframe, but I need to only display part of the page, not the whole thing. My current code is: <div style="display:block;overflow:hidden;width:500px;height:350px;"> <iframe height="350px" scrolling="no" src="http://my/page/i/want/to/show/part/of/here/" width="500px"></iframe></div> I thought that the best option would be to serve the iframe within a containing div that has "overflow:hidden" so that it acts like a picture frame. That works, but the