简体   繁体   English

JavaScript弹出窗口CSS并单击功能

[英]Javascript pop up window css and click function

I have a pop up window which contains form to fill out the details. 我有一个弹出窗口,其中包含用于填写详细信息的表单。 My need is, I need to show the form inside the pop up window with the css styles applied to it. 我需要的是,我需要在弹出窗口中显示具有应用CSS样式的表单。

Currently I have loaded the form inside the pop up window but it is not taking the style applied to it. 目前,我已经在弹出窗口中加载了表单,但是没有采用所应用的样式。 How do I get the styles to be applied on it. 如何获得要应用的样式。 (I don't want to load the .html page in windows pop up) (我不想在Windows弹出窗口中加载.html页面)

When I click on the submit link in the pop up, it should clone the .clone div on the page and pop up should get closed. 当我单击弹出窗口中的.clone链接时,它应在页面上克隆.clone div并关闭弹出窗口。

here is my current js 这是我目前的js

function myFunction() {
    var myWindow = window.open("", "MsgWindow", "width=500, height=400");
    myWindow.document.write($(".content").html());
    myWindow.document.close();
}

DEMO 演示

Any help is much appreciated. 任何帮助深表感谢。 Thank you! 谢谢!

put ur css inside the div ' content ' 将ur css放入divcontent

check this link http://jsfiddle.net/erv3ebj1/5/ 检查此链接http://jsfiddle.net/erv3ebj1/5/

Adding some like this may work 像这样添加一些可能

myWindow.append($("<link/>", 
    { rel: "stylesheet", href: "file://path/to/style.css", type: "text/css" }));

尝试在隐藏的iframe中打开它,直到需要它为止。

Put CSS under content div and use internal css <style> . 将CSS放在content div并使用内部css <style>

I would advice to use it before form tag 我建议在form标签之前使用它

Demo 演示版

Please try this one: 请试试这个:

function myFunction() {
    var myWindow = window.open("", "MsgWindow", "width=500, height=400");

    myWindow.document.write($(".content").html());

    myWindow.document.close();

    }

DEMO 演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM