2012-07-21 56 views
0

我有一个带有完整html代码(html,head,body)的javascript变量,而不仅仅是body内容。现在我需要将该代码渲染到另一个html页面。将html var加载到另一个html元素中

一个IFRAME SRC没有通过jQuery的伟大工程装载代码:

$("#myIframe").contents().find('html').html(myJsVar); 

,但我不能赶在iframe中keyup事件,这是强制性的。

我期望的解决方案是使用可渲染页面的DIV,但我认为这是不可能:(

你有任何其他的想法?

非常多的感谢!

+0

的'iframe' – Linuxios 2012-07-21 15:36:00

+0

围绕'div'你有没有细读现有的答案一样http://stackoverflow.com/a/1 933220/30007或http://stackoverflow.com/a/4914914/30007或http://stackoverflow.com/a/10942878/30007 ...尝试搜索一下SO。 – 2012-07-21 15:45:51

回答

0

这似乎很简单:jsFiddle example

$('#myIframe').contents().find('#myInput').keyup(function() {$(this).val('new value');});​ 
相关问题