473,658 Members | 2,628 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Embed the javascript file.

Hi, Dear guru,

I have a question on embed a javascript into the master page.

I put the following line
<link runat="server" type="text/javascript" href="~/column.js" />

under the head, but obviously, it's not called anywhere.
But if I put this line,
<script type="text/javascript" src="column.js" ></script>, it worked.

But I think i have to use the first approach since the second approach
will use an absolute path, and won't resolve in other pages which
include the master page.

Is there anyway around this issue

Thanks for help.
Apr 13 '06 #1
2 1365
Here is how you can do it

define the <head> tag in the master page to be a server side control as
this :
<head runat="server">

Then in Page_Init event of master page add the following :
HtmlLink link = new HtmlLink();
link.Href = "~/column.js";
link.Attributes .Add("type", "text/javascript");
Page.Header.Con trols.Add(link) ;

HTH !
--
Swanand Mokashi
Microsoft Certified Solution Developer (.NET) - Early Achiever
Microsoft Certified Application Developer (.NET)

http://www.dotnetgenerics.com/
DotNetGenerics. com -- anything and everything about Microsoft .NET
technology ...

http://www.swanandmokashi.com/
http://www.swanandmokashi.com/HomePage/WebServices/
Home of the Stock Quotes, Quote of the day and Horoscope web services
"Jianwei Sun" <js***********@ gmail.com> wrote in message
news:um******** ******@TK2MSFTN GP02.phx.gbl...
Hi, Dear guru,

I have a question on embed a javascript into the master page.

I put the following line
<link runat="server" type="text/javascript" href="~/column.js" />

under the head, but obviously, it's not called anywhere.
But if I put this line,
<script type="text/javascript" src="column.js" ></script>, it worked.

But I think i have to use the first approach since the second approach
will use an absolute path, and won't resolve in other pages which include
the master page.

Is there anyway around this issue

Thanks for help.

Apr 13 '06 #2
Thanks for the reply,

Here is what is generated in header section after implementing your
suggestions.
<link href="column.js " type="text/javascript" />

But it seems it's still not called, is that because my javascript is wrong.

[Javascript code ]

function setTall() {
if (document.getEl ementById) {
//Adjust the column height here....
}
}

window.onload = function() {
setTall();
}

window.onresize = function() {
setTall();
}

But if I uncomment this line, it works...

<script type="text/javascript" src="column.js" ></script>
Any other suggestions, thanks.

Swanand Mokashi wrote:
Here is how you can do it

define the <head> tag in the master page to be a server side control as
this :
<head runat="server">

Then in Page_Init event of master page add the following :
HtmlLink link = new HtmlLink();
link.Href = "~/column.js";
link.Attributes .Add("type", "text/javascript");
Page.Header.Con trols.Add(link) ;

HTH !

Apr 13 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
5216
by: Tony Sutton | last post by:
I have this following code in my html file: <object classid="clsid:166B1BCA-3F9C-11CF-8075-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab# version=7,0,0,0" width="320" height="320"> <param name="src" value="file.dcr" /> <embed src="file.dcr" pluginspage="http://www.macromedia.com/go/getflashplayer" width="320" height="320"> </embed>
1
3303
by: majestik | last post by:
Question, can I see an event in Javascript that tells me a video starts playing using the <embed src="file.wmv>. I stream the video, but there is a wait time and wanted to pop up a message telling the user it is buffering until the video actually begins to play in the browser. Thanks for any help! JJ
3
4789
by: abrtlt | last post by:
I would like to have a web page in which, when the user clicks on any of several specific elements, a specific audio file is played, without reloading the page. The specific audio file name is obtained from a PHP script (accessing a MySQL database) that could be called using XMLHttpRequest and JavaScript would write in a "div" tag an "embed and play" HTML tag containing the audio file name. I am not sure this would work, as the embed tag...
3
2565
by: Anil Gupte | last post by:
I want to embed using an embed tag or object tag (like YouTube or others do) to embed a video file in a web page. I want to know if there is an event related to the video being done playing. Also are there other events? Thanx in advance, -- Anil Gupte www.keeninc.net www.icinema.com
2
4326
polymorphic
by: polymorphic | last post by:
I am no longer good at Javascript and need help. I'm trying to embed pdf files in html then build some sort of navigation between the pdfs via the pdf numbered file name. I can generate the javascript functions to extract and manipulate strings, ints, etc but can't seem to deal with the variables I produce. For instance, if current embedded pdf filename is "1.pdf" and button "Next" is clicked then embed "2.pdf". I cannot seem to get the...
5
2163
by: elbin | last post by:
Hello, first to say that I am a total beginner in Javascript but I know some programming (python in particular) and am able to understand methods/parameters and so on. Here's my problem: I am trying to set up a page that changes every time it's visited, but without using php(which i don't know either) because it's not active on the server. The thing that should change is a single number in one attribute of an <embed> tag inside an <object>....
1
6244
by: ShahzadMahmood | last post by:
I want to embed the following code in javascript function javascript function is written just after the object code, I want to replace the popup window code with this object code while the file name will be received in function parameter. <object classid="clsid:166B1BCA-3F9C-11CF-8075-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=10,0,0,0" ID=Child1 width=820 height=621> <param name=src...
2
8069
dream party
by: dream party | last post by:
Inserting a Flash (SWF, FLV) file into HTML web page is already an old and familiar thing to all of us. It is a rather non-flexible thing that just to edit some options in the template. However, I did not understand some parameters totally in the HTML tag. These days when I was surfing the Internet I have found some comprehensive introduction to these two tags. I read it and conclude it with my own words; I think it will be useful to us, so I...
0
8427
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8330
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8523
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8626
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7355
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4334
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2749
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.