1

phonegap アプリで Web ページを表示し、表示をオーバーライドする neww css ファイルを適用できるようにする必要があります。または、css を使用しない別の方法があるのでしょうか?

デスクトップで mozilla を使用して Web ページを開くと、firebug を使用して css を微調整して、必要な外観を得ることができるため、これが可能でなければならないことはわかっています。変更する必要があるのは寸法だけなので、iframe は使用できません。モバイルアプリでスクロールしたくないので、少し縮小する必要があります。これは、フラッシュを有効にする必要があると思われるため、これがまだ機能しない可能性があると感じているコードです(ロードしようとしているページはライブストリームです)が、これらの変更が最初に何をするかを確認したい

index.html:

<!DOCTYPE html>
<html>
<head>
<title>Hello Phonegap</title>

    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" />
    <meta charset="utf-8">


    <script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
    <script src="jquery-mobile/jquery-1.6.4.min.js" type="text/javascript"></script>
    <script src="jquery-mobile/jquery.mobile-1.0.min.js" type="text/javascript"></script>
    <link rel="stylesheet" href="theme.css" />
    <link rel="stylesheet" href="theme.min.css" />
    <script type="text/javascript" charset="utf-8" src="childbrowser.js"></script>
    <script type="text/javascript">




   function onBodyLoad()
    {       
        document.addEventListener("deviceready", onDeviceReady, false);
    }

    function onDeviceReady()
    {
        // do your thing!
        navigator.notification.alert("Phonegap is ready")
    }

    </script>
<link href="jquery-mobile/jquery.mobile.structure-1.0.min.css" rel="stylesheet" type="text/css">
</head>
<body onload="onBodyLoad()">
    <!-- Home -->
<div data-role="page" id="page1">
        <div data-role="content">
          <ul class="ui-btn-up-a" data-role="listview" data-theme="a">
            <li><a href="#">Page</a></li>
            <li><a href="#">Page</a></li>
            <li><a href="#">Page</a></li>
            <li class="ui-bar-a"><a href="#" onClick= "window.plugins.childBrowser.showWebPage('http://www.google.com');">child</a></li>
          </ul>

        </div>

    </div>
  </div>

config.xml

<?xml version="1.0" encoding="UTF-8" ?>
<widget xmlns = "http://www.w3.org/ns/widgets"
xmlns:gap = "http://phonegap.com/ns/1.0"
id        = "com.phonegap.example"
version   = "1.0.0">

<name>PhoneGap Build Application</name>

<description>
A simple PhoneGap Build application.
</description>

<author href="https://example.com" email="you@example.com">
Your Name
</author>
<gap:plugin name="ChildBrowser" />
<access origin="*" />

</widget>
4

2 に答える 2

0

新しい css ファイルを追加するには、次を使用します。

var obj=document.createElement("link");
obj.setAttribute("rel", "stylesheet")
obj.setAttribute("type", "text/css")
obj.setAttribute("href", your_css_file)
obj.setAttribute("id", id_to_remove_it_later);
document.getElementsByTagName("head")[0].appendChild(obj);

それが役に立てば幸い

于 2013-03-28T20:40:49.807 に答える