Hello every one,
I know how to register a client script that is on my web page, but I would like to know how to register my script when the script is in another file. Does anyone know how to register a file containing java script file. This is my code for calling the function when it's in the page.
This is the code behind for my button.HTML Code:<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %> <!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"> <script language="javascript" type="text/javascript" > function openNewWin(url) { var x = new Object; x = window.open(url, 'mynewwin', 'width=600,height=600,toolbar=1'); } </script> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:Button ID="btnOpenPop" runat="server" Text="Open Pop" /> </div> </form> </body> </html>
I have the exact same function in a javascript file (Jscript.js) in the root directory. I know I need the src property to idenify the file, but how do I register the whole script file and call the function?Code:Protected Sub btnOpenPop_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnOpenPop.Click Dim url As String = "http://www.yahoo.com" ClientScript.RegisterStartupScript(Me.GetType(), "OpenWin", "<script>openNewWin('" & url & "')</script>") 'How do I register script in an external file called JScript.js End Sub
This is the code in my javascript file
If anyone can help me I would appreciate it.Code://// Jscript.js ///// function openNewWin(url) { var x = new Object; x = window.open(url, 'mynewwin', 'width=600,height=600,toolbar=1'); }
Thanks




Reply With Quote