[英]Web app inside iframe change the parent window location
我有一頁正在使用標簽。 作為此iframe的來源,我正在傳遞一個外部Webapp。 現在,當此應用程序正在加載時,其主頁上將包含用於檢查該應用程序是在框架內還是在父窗口中加載的代碼。 如果它不在父窗口中,那么它將獲得對父窗口的引用,並以使其在父窗口中顯示的方式更改位置。 現在,我無法控制該Web應用程序,因此無法更改其主頁,是否有任何解決方法可以停止此應用程序以更改其父窗口位置。 這是我正在使用的示例代碼。 我無法提供內部webapp的網址。 在我看到alter msg“ test”之前,webapp正在更改父窗口的位置。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Example</title>
<style type="text/css">
</style>
<script type="text/javascript">
// <![CDATA[
window.onload = function()
{
alert('test');
//frames["my_iframe"].onload = function()
//{
//alert("hey");
//}
//this also works for me:
document.getElementById("my_iframe").onload = function()
{
alert("hey");
}
}
// ]]>
</script>
</head>
<body>
Testing iframe....<br>
<iframe name="my_iframe" id="my_iframe" src="http://mywebapp.com" width="100%" height="100%" ></iframe>
</body>
</html>
您正在嘗試執行所謂的XSS或跨站點腳本編寫,由於明顯的原因,由於安全性機制,在任何現代瀏覽器中都無法做到這一點。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.