html - 如何使用 WebView 加载 Google Play 页面?
问题描述
我使用 Ionic 3。此代码适用于其他网站,但使用 Google Play 的 url 它不起作用。如何使用 WebView 加载 Google Play 页面?
import { Component } from '@angular/core';
import { NavController, Platform } from 'ionic-angular';
import { InAppBrowser, InAppBrowserOptions } from '@ionic-native/in-app-browser';
declare var navigator: any;
declare var Connection: any;
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
Connection: any;
isLaunch: Boolean = false;
constructor( private platform: Platform, private iab: InAppBrowser) {
this.platform.ready().then(() => {
this.launch();
});
}
launch() {
this.isLaunch = true;
const browser = this.iab.create('https://play.google.com','_self' , "location=yes");
browser.show();
}
}
<ion-content>
<iframe width='100%' height='100%'
src="https://play.google.com/" frameborder="0" allowfullscreen>
</iframe>
</ion-content>
先感谢您。
解决方案
You won't be able to do this.
You are trying to load Google Play in a frame from a different domain name. If Google allowed this, it would be a big security risk, for example, it might let you trick the user into clicking on your site when they thought they were clicking on Play.
In order to prevent this, Google, and other sites use the "X-FRAME-OPTIONS" header set to "SAMEORIGIN". This tells the browser to not allow this to be put in an iframe unless the source URL also comes from play.google.com
. Lots of other web pages do this too. You can see this if you open play.google.com
in chrome, and use the developer tools to look at the header on the request.
推荐阅读
- html - jQuery - 悬停时淡入图像,之后淡出
- python - np.tril 不会使事情完全为 0
- javascript - 单击按钮时将文本插入另一个页面上的元素
- sed - 如何解析 sed 正则表达式语法?
- swift - 使用 UIViewControllerRepresentable 在 SwiftUI 中实现图像选择器时出现内存泄漏
- python - Python 中的 Hardy Cross
- python - GUIZERO可以通过传感器开发吗?如果可能,怎么做?(使用 If Elif 和 Else 语句?)
- json - PostgreSQL - 在更新完成之前运行创建索引
- php - 在 Symfony 中找不到调用成员函数 isPasswordValid() on null 的解决方案
- javascript - 如何查看表中的所有数据并按当前创建日期设置默认列表?