6

I am using 'net.rim.device.api.browser.field2.BrowserField' for loading an html page with 2 scripts.

  1. script 1 (Jquery)
  2. script 2 (Jquery mobile)

The 2nd script gets loaded twice. Its like the script gets loaded no. of times as per its position in the html file.

eg : 5th position script file will get loaded 5 times and respectively.

Thanks in advance.

RATTLESNAKE
  • 3,218
  • 2
  • 21
  • 24

1 Answers1

0

I've been trying to reproduce, and am failing. Consider this simple BB app:

package mypackage;

import net.rim.device.api.browser.field2.BrowserField;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.container.MainScreen;

public class MyApp extends UiApplication
{
    final class MyScreen extends MainScreen
    {
        protected BrowserField browser;
        protected static final String URL = "http://www.craigmj.com/bbtest/index.html";

        public MyScreen()
        {        
            setTitle(URL);          
            browser = new BrowserField();
            add(browser);
            browser.requestContent(URL);
        }
    }

    public static void main(String[] args)
    {
        MyApp theApp = new MyApp();       
        theApp.enterEventDispatcher();
    }

    public MyApp()
    {        
        pushScreen(new MyScreen());
    }    
}

Now the index.html it loads looks like this:

<html>
<head>
    <script language="javascript" src="js1.js"></script>
    <script language="javascript" src="js2.js"></script>
    <script language="javascript" src="js2.js"></script>
    <script language="javascript" src="js3.js"></script>
    <script language="javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script language="javascript">
function loadFn() {
    res = "";
    for (var i=1; i<4; i++) {
        res += "js" + i + " = " + getCount("js"+i) + ", ";
    }
    document.getElementById("val").value = res;
}
    </script>
</head>
<body onLoad="loadFn();"><h1>Loading...</h1>
    <input type="text" id="val" name="val" size="30"/>
</body></html>

js1.js is:

function jsCount(jsFile) {
    if ("undefined"==typeof window[jsFile]) {
        window[jsFile] = 0;
    }
    window[jsFile] = window[jsFile] + 1;
}

function getCount(jsFile) {
    return window[jsFile];
}

jsCount("js1");

And js2.js and js3.js are:

jsCount("js2");

and

jsCount("js3");

(You can find them at http://www.craigmj.com/bbtest/...)

And I'm getting the results I expect on the 9700 simulator, and on my 9900 device.

js1 = 1, js2 = 2, js3 = 1,

It doesn't work on the Blackberry 5 OS, but that appears to be because the browser on BB5 doesn't support script tags.

Can we get some clarity on exactly where and how this error can be reproduced?

craigmj
  • 4,827
  • 2
  • 18
  • 22