Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PhoneGap Iframe Not Working

Tags:

cordova

I'm developing an application with PhoneGap I use iframe alone, how do I overcome it does not load the iframe field

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="viewport" content="width=device-width, user-scalable=no" />
    <link rel="stylesheet" type="text/css" href="css/index.css" />
    <title>Hello World</title>
</head>
<body>

    <div class="loader"></div>

    <div class="iframe">
        <iframe name="iframeName" width="320" height="480">></iframe> 
    </div>

    <script type="text/javascript" src="js/jquery-3.0.0.min.js"></script>
    <script type="text/javascript">
        $("[name=iframeName]").attr("src", "http://dnsmarket.net/pdf");
    </script>

</body>
</html>
like image 301
Can Aytekin Avatar asked Jun 22 '16 13:06

Can Aytekin


1 Answers

You are loading content into an iframe in the main web view, which requires you to allow access to that content in the config.xml file.

By adding the following in config.xml, you allow the main web view to navigate to your URL when loading the iframe contents, and this then works:

<allow-navigation href="http://dnsmarket.net/*" />

I tested this with iOS and Cordova 6.2.0 and it works fine with the above change. I used your index.html as posted.

Documentation describing how to configure allow-navigation can be found here.

like image 106
Simon Prickett Avatar answered Nov 19 '22 12:11

Simon Prickett