Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
New Developer
Posts: 11
Registered: ‎04-16-2009
My Device: Not Specified

External Javascript files

Blackberry model: 8830

OS version 4.2

Blackberry browser

 

When I use external javascript files, the functions are not called. The same javascript functions if include in side the html file they work. Is there any changes to be made to javascript files, so that the browser can load and call the functions.

 

Thanks 

Guru I
Posts: 19,020
Registered: ‎07-29-2008
My Device: Passport, Playbook, 9320BES
My Carrier: Bouygues _ SFR

Re: External Javascript files

there is probably a problem with your < script > element.
can you publish both the HTML file and the javascript file ?

does the HTML file validate at http://validator.w3.org/ ?



The search box on top-right of this page is your true friend, and the public Knowledge Base too:
New Developer
Posts: 11
Registered: ‎04-16-2009
My Device: Not Specified

Re: External Javascript files

The same script which I keep in the external file works well, if the script is placed inside the <script></script> tags in HTML. If needed I will post the files.

 

 

 

My Form code:

=========== 

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="BBTest.aspx.vb" Inherits="BlackBerry_BBTest" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Log In</title>

<script language ="javascript" type ="text/javascript" >

 function ShowMsg()

{

window.alert(
'Please Login into the system');

}

</script>

</head>

<body onload ="ShowMsg();">

<form id="form1" runat="server">

<table style="width: 320px">

<tr>

<td>

User Name</td>

<td>

<asp:TextBox ID="txtUserName" runat="server"></asp:TextBox></td>

</tr>

<tr>

<td>

Password</td>

<td>

<asp:TextBox ID="txtPassword" runat="server"></asp:TextBox>

</td>

</tr>

<tr>

<td>

<asp:Button ID="btnsubmit" runat="server" Text="Submit" />

</td>

<td>

<asp:Button ID="btnCancel" runat="server" Text="Cancel" /></td>

</tr>

</table>

 </form>

</body>

</html>

========== 

End of Form code:

 

the ShowMsg works perfectly if I keep the cod ein script tags

 

But the same ShowMsg does not work if I keep in an external file BBTest.js and called using

<script language="javascript" src="BBTest.js" type="text/javascript"></script>

 

 

Thanks

Satya

 

 

Developer
Posts: 189
Registered: ‎08-13-2008
My Device: Not Specified

Re: External Javascript files

I did a quick test and it works fine for me.I tested it on a 8830 v4.2.2

 

http://www.cesarcaballeroart.com/test2.htm

 

Andrew

New Developer
Posts: 11
Registered: ‎04-16-2009
My Device: Not Specified

Re: External Javascript files

Hi Andrew,

 

Thank you for the reply. Its working If I keep the code in .htm file. But if I save it as .aspx file, then ots not working. Any suggetions to make it work thru aspx file. I am creating the pages using visual studio.

 

Thanks again for the help.

 

Satya

Guru I
Posts: 19,020
Registered: ‎07-29-2008
My Device: Passport, Playbook, 9320BES
My Carrier: Bouygues _ SFR

Re: External Javascript files

the javascript code file should be named with a ".js" extension.



The search box on top-right of this page is your true friend, and the public Knowledge Base too:
New Developer
Posts: 11
Registered: ‎04-16-2009
My Device: Not Specified

Re: External Javascript files

I named the file as BBTest.js
New Developer
Posts: 11
Registered: ‎04-16-2009
My Device: Not Specified

Re: External Javascript files

do we have to make any changes in the javascript file
Guru I
Posts: 19,020
Registered: ‎07-29-2008
My Device: Passport, Playbook, 9320BES
My Carrier: Bouygues _ SFR

Re: External Javascript files

can you publish the .js file and the html file on a webserver and give us the URL?



The search box on top-right of this page is your true friend, and the public Knowledge Base too:
New Developer
Posts: 11
Registered: ‎04-16-2009
My Device: Not Specified

Re: External Javascript files

Actually I am behind a proxy/firewall. I can send you the apsx file and the javascript files. i actually pasted the code earlier. If the file is html file like what andrew published, it works. But if it is aspx its not working.

 

Thanks

Satya