从iframe访问父级主题

时间:2021-12-09 15:56:14

I have a Web application that is accessed via iframe, with user login.

我有一个通过iframe访问的Web应用程序,用户登录。

It does detect the user login and conforms accordingly.

它确实检测用户登录并相应地进行协调。

So how could I integrate the look and feel (or theme) of the parent page into the Web app?

那么我怎样才能将父页面的外观(或主题)集成到Web应用程序中?

Thanks.

2 个解决方案

#1


If you mean something like:

如果你的意思是:

<html>
<head>
<title>Page on foo.com</title>
</head>
<body>
<iframe src="http://bar.com/login"></iframe>
</body>
</html>

and you want bar.com/login to look like foo.com, that's impossible without foo.com's cooperation. You won't be able to access the foo DOM from your iframe, as that would be cross-domain scripting.

并且你希望bar.com/login看起来像foo.com,如果没有foo.com的合作,这是不可能的。您将无法从iframe访问foo DOM,因为这将是跨域脚本编写。

#2


If you have control of the page being loaded in the iframe you can add a reference to one of the parent's css files.

如果您可以控制在iframe中加载的页面,则可以添加对父级css文件之一的引用。

#1


If you mean something like:

如果你的意思是:

<html>
<head>
<title>Page on foo.com</title>
</head>
<body>
<iframe src="http://bar.com/login"></iframe>
</body>
</html>

and you want bar.com/login to look like foo.com, that's impossible without foo.com's cooperation. You won't be able to access the foo DOM from your iframe, as that would be cross-domain scripting.

并且你希望bar.com/login看起来像foo.com,如果没有foo.com的合作,这是不可能的。您将无法从iframe访问foo DOM,因为这将是跨域脚本编写。

#2


If you have control of the page being loaded in the iframe you can add a reference to one of the parent's css files.

如果您可以控制在iframe中加载的页面,则可以添加对父级css文件之一的引用。