Javascript:数组中的文本和多个textareas

时间:2016-01-31 20:01:05

标签: javascript css

我正在尝试将父页面加载到对象标记中,虽然我可以收到警告以显示我已经获得了代码,但我无法将其放入< object>有线索吗?

    var page=parent.document.documentElement.innerHTML;
    alert(page);
    document.getElementById('close_skin').style.visibility="visible";
    document.getElementById('show_skin').style.visibility="visible";
    document.getElementById('show_skin').setAttribute("data",page);

假设我可以让代码出现,我怎样才能“切换”到另一组样式?父级使用“.xxx_fixed”类,但对象中的代码需要使用“.xxx_float”类,这些类也位于页面顶部的模板CSS中。 (当我在另一个PERL程序中执行此操作时,只需将< body>中的标记从“class ='xxx_fixed'”重命名为“class ='xxx_float'”(无法通过全局轻松完成此操作) javascript替换,因为它也会重命名代码顶部的类!)

我刚刚尝试在var页面对象的顶部添加一些脚本 - 如果我可以让代码出现,它可以工作......

    +'document.getElementById(\'icon_outer\').setAttribute(\'class\', \'icon_outer_float\')'

如果您对“为什么”感兴趣,在全屏浏览器中查看时,“固定”保留菜单/顶栏会固定在一个位置,但“浮动”会使所有内容在< object&gt中一致移动; “窗口”允许观看者像模仿静态放大镜一样平移模板页面;

    .menu_back_float{position:relative;top:0px;background-color:#f5eca4;min-height:520px;height:auto}
    .menu_back_fixed{position:relative;top:35px;background-color:#f5eca4;min-height:550px;height:auto}

1 个答案:

答案 0 :(得分:0)

要将父页面加载到<object>元素,您必须指定页面的URL。要获取代码并将其放在警告框中,您可以使用jQuery的$.get()方法(只要您通过代理域加载它),如下所示:

HTML:

// I'm just using W3Schools just to save time
<object data="http://www.w3schools.com/" width="1500" height="1200">
     <embed src="http://www.w3schools.com/" width="1500" height="1200"></embed>
     Your browser does not support the object tag.
</object>

JavaScript的:

window.jQuery.get("http://www.yourdomain.com/?url=www.w3schools.com", function(response) {
   window.alert(response);
}

对于问题的第二部分,您可以使用jQuery将类的名称从.xxx_fixed更改为.xxx_float

function main() {
    $('object').removeClass('xxx_fixed').addClass('xxx_float');
}

$(document).ready(main);

希望我已经正确地回答了你的问题,如果我没有,请随时告诉我,以便我可以编辑。