2
Every time I put an iframe, instead of opening it inside the page, the iframe opens in full screen. It follows project codes
Mainactivity.java
package com.example.duff.webviewoficial;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().hide(); //aqui a mágica REMOVE A BARRA DE TITULO
getWindow().setFeatureInt( Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);
setContentView(R.layout.activity_main);
WebView mWebView = (WebView) findViewById(R.id.activity_main_webview);
// Enable Javascript
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true); // Aparentemente habilitado
mWebView.setWebViewClient(new WebViewClient()
{
public boolean shouldOverrideUrlLoading(WebView view, String url){
view.loadUrl(url);
return false;
}
});
Androidmanifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.duff.webviewoficial">
<application
android:allowBackup="true"
android:icon="@mipmap/logo_home_icon"
android:label="FarmaLivPlayer"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
Page with home.html problem
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no">
<link rel="stylesheet" type="text/css" href="view/matriz.css">
<link rel="stylesheet" type="text/css" href="view/produtos.css">
<link rel="stylesheet" type="text/css" href="view/paginas.css">
<script type="text/javascript" src="js/banner.js"></script>
<script type="text/javascript" src="js/farmaLivPlayer.js"></script>
<!-- evita abrir em iframe -->
<script>if (self != top) { top.location.replace(window.location.href) }</script>
<!-- evita abrir em iframe -->
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="view/master.css">
<title></title>
</head>
<body onload="temporizarSlide()">
<div id="tudo" >
<div id="topo" class="transparente">
<div id="botaoMenu" class="botoesTopo">
<button class="js-menu-show header__menu-toggle material-icons"></button>
</div>
<a href="javascript:home()"><div id="logo" class="botoesTopo"></div></a>
<a href="javascript:cestinha()"><div id="botaoCestinha"></div></a>
<div id="botaoLupa" ></div>
</div>
<div id="navegacao">
<div id="banner" >
<div id="alvoBanner" style="position: relative; width: 100%; height: 100%; background-color: #ccc;">
<img src="view/img/sliders/1slide.png" width="100%" height="100%">
</div>
<a href="javascript:cliquePushDown()"><div id="pushDown" style="position: absolute;bottom: 0%;left: 50%; ;" onclick="cliquePushDown();"></a>
<a href="javascript:cliquePushDown()"><img src="view/img/sliders/pushDownBotao.png" width="100%" height="100%"></a>
</div>
</div>
<div id="sugestoes" >
<div id="sugestoesFarmaLiv" class="block"></div>
<div id="produtosContainer">
<iframe src="produtosApp/index.html" width="100%" height="100%" frameborder="0" scrolling="0"></iframe>
<div id="blockEsquerdo">
</div>
<div id="blockDireita">
</div>
</div>
</div>
<div id="parceiros" class="transparente">
</div>
</div> <!-- fim da navegacao -->
<div id="botoesFooter" class="transparente">
<div id="botaoHome" class="botoesFooter" onclick="home()"></div>
<div id="botaocategorias" class="botoesFooter" onclick="categorias()"></div>
<div id="botaoDicasDeSaude" class="botoesFooter" onclick="dicasDeSaude()"></div>
<div id="botaoPerfil" class="botoesFooter"></div>
</div>
</div>
</div>
<aside class="js-side-nav side-nav">
<nav class="js-side-nav__container side-nav__container">
<button class="js-menu-hide side-nav__hide material-icons">X</button>
<header class="side-nav__header">
</header>
<ul class="side-nav__content">
<li><a href="home.html">Início</li>
<li><a href="busca.html">Busca</li>
<!-- código Alerta de Saúde deletado -->
<li><a href="categorias.html">Categorias</li><li><a href="dicasDeSaude.html">Dicas de saúde</li><li><a href="alertaDeSaude.html">Alerta de saúde</li><li><a href="#">Meus pedidos</li><li><a href="#">Minha conta</li>
</ul>
</nav>
</aside>
<script src="js/side-nav.js"></script>
<div id="seletorImagem">
</div>
</body>
</html>
You once looked here: https://www.npmjs.com/package/cordova-plugin-fullscreen
– viana
I use both Cordova and android studio. I have no problems in Cordova to open iframe. My problem is in Android Studio. iframe refuses to open inside another page. It loads in full screen. Really, I just wanted a status bar in the app (battery, carrier signal, time), thing that Android Studio gives me easy, and phonegap/Ordova do not know how to do. In android studio I have status bar, but I don’t have iframe. In Cordova, I have iframe, but I don’t have status bar. I’m lost kkk
– Paulo Sérgio Duff
There where is your getSupportActionBar(). Hide();, is this working normally? If you take it off it will show the title bar because Hide does the job of hiding.
– viana
I just checked! It’s working perfectly. So much so that I removed the line and the title bar came back.
– Paulo Sérgio Duff
My difficulty is in displaying iframe inside a webview in android studio. That doesn’t happen! iframe opens in full screen (edited)!
– Paulo Sérgio Duff
Basically you want the webview not to open in full screen, right?
– viana
Let’s go continue this discussion in chat.
– Paulo Sérgio Duff
I think I understand your doubt, you have a webView page and this page has an iframe, but for some reason iframe is redirecting the page
top
to the iframe address itself, would that be? Or is iframe being invoked in the default browser?– Guilherme Nascimento
to the own iframe address... That’s right! Ignoring the page that contained the iframe, and opening the iframe page.
– Paulo Sérgio Duff