无法在android html app中加载外部js文件

时间:2016-01-28 21:55:00

标签: javascript android html5

我正在尝试将位于我的网络服务器上的外部js文件加载到我的Android应用程序(HTML5)中,但它无法正常工作。当我在我的PC浏览器上尝试html文件时,它工作正常,但在Android浏览器中它不起作用。

<script src="http://myserver.com/file.js" language="javascript" type="text/javascript"></script>

是否有我必须添加到我的Android配置的权限!!

清单

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:hardwareAccelerated="true" android:versionCode="" android:versionName="1.0.0" android:windowSoftInputMode="adjustPan" package="com.application.store">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true"/>
<uses-permission android:name="android.permission.INTERNET"/>
<application android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="Pets">
 <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="Pets-Book" android:name="MainActivity" android:theme="@android:style/Theme.Black.NoTitleBar">
  <intent-filter>
    <action android:name="android.intent.action.MAIN"/>
    <category android:name="android.intent.category.LAUNCHER"/>
    <category android:name="android.intent.category.DEFAULT"/>
  </intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.CALL_PHONE"/>  
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="22"/>
</manifest>

1 个答案:

答案 0 :(得分:0)

是的,您必须添加

    Option Explicit

Private Const WM_USER As Long = &H400&
Private Const EM_GETOLEINTERFACE As Long = WM_USER + 60
Private Const EM_SETTYPOGRAPHYOPTIONS As Long = WM_USER + 202
Private Const TO_ADVANCEDTYPOGRAPHY As Long = 1

Private Declare Function SendMessage Lib "user32" Alias "SendMessageW" ( _
    ByVal hWnd As Long, _
    ByVal wMsg As Long, _
    ByVal wParam As Long, _
    ByVal lParam As Long) As Long

Private Document As tom.ITextDocument

Private Sub cmdJustify_Click()
    'Justify the text of the first paragraph:

    'Select first paragraph in the document.
    With Document.Range(0, 0)
        .MoveEnd tomParagraph, 1
        .Para.Alignment = tomAlignJustify 'Apply justification.
        .Collapse tomStart 'Collapse the selection.
    End With
End Sub

Private Sub Form_Load()
    Dim Unknown As Object

    SendMessage rtb.hWnd, EM_GETOLEINTERFACE, 0, VarPtr(Unknown)
    Set Document = Unknown
    SendMessage rtb.hWnd, _
                EM_SETTYPOGRAPHYOPTIONS, _
                TO_ADVANCEDTYPOGRAPHY, _
                TO_ADVANCEDTYPOGRAPHY

    rtb.LoadFile "Resources\Sample1.rtf"
End Sub

到AndroidManifest.xml

您还必须调用

    <uses-permission android:name="android.permission.INTERNET"/>

让它发挥作用