473,748 Members | 10,569 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Locate the Tag where a specific function is positioned?

Hi I dynamically insert some stylesheets. I want them to be placed
before some javascript is executed. I know I can add an id to the
scripttag that I want the stylesheets to be insert above, but I then
have a problem with with backward compability(nee d to insert that id
to many pages) and I have a problem if my colleagues forget to add
that id to the script tag.

My question is can I locate a javascript funtion - ie I have a
initPage function that I know should
always be on the page - can I locate what script tag element that
function is located in and then use that to insert the stylesheets
above that script tag? How do I locate the script tag? I cannot be
sure that the script tag is always the last on the page.

Thanks in advance

Jun 3 '07 #1
1 1246
On Jun 3, 6:20 pm, "Thomas K. Nielsen" <thoni...@gmail .comwrote:
Hi I dynamically insert some stylesheets. I want them to be placed
before some javascript is executed. I know I can add an id to the
scripttag that I want the stylesheets to be insert above, but I then
You can try, but the HTML 4 specification doesn't include an id
attribute for script elements, so I would expect some browsers to not
support it.

In valid HTML, style elements should only appear in the head.
Browsers may take notice of script elements in the body, but the
results may not be what you expect).

have a problem with with backward compability(nee d to insert that id
to many pages) and I have a problem if my colleagues forget to add
that id to the script tag.

My question is can I locate a javascript funtion - ie I have a
initPage function that I know should
always be on the page - can I locate what script tag element that
function is located in and then use that to insert the stylesheets
above that script tag? How do I locate the script tag? I cannot be
sure that the script tag is always the last on the page.
Similar questions have been asked in the past, like "can a function
tell which script element it's in?" and the answer to that is a
qualified yes (search the archives). However, I don't think you can
do what you are after. If you explain a little further, you might get
a solution that suits.

I guess you want the style sheets added only if a particular function
is in the page. My suggestion would be to add the stylesheets to the
head using a function before calling your particular function (say
using your initPage function).
--
Rob
Jun 3 '07 #2

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

Similar topics

2
8648
by: Rainer Kugeland | last post by:
Two problems regarding coordinates: a) When I click in the screen then I can easyly find the element on the current corrdinates. But is there a way to find the elements which are behind the fist on the z-axis? b) Is there a fast way to find all elements which are within specific coordinates like 100,100 and 200,200? Currently I walk through the whole tree and calculate the absolute positions of each elements. It works but it's really...
7
4756
by: qwerty | last post by:
Following works in Mozilla, Opera and IE. <div style=" left: 100px; right: 200px; /* JavaScript-hack for IE*/ width: expression((document.body.clientWidth - 100 - 200) + 'px') "> <span>Text<span> <div>
4
16144
by: Philipp Lenssen | last post by:
Is it possible in IE6+NS7 to center-align a div of fixed width which itself contains elements which use "position: absolute"? Using "margin-left: auto" and "margin-right: auto" works well to center something, but the absolute-positioned contents of the outside layer will be stuck to the left of the window...! Thanks a lot! -- Google Blogoscoped http://blog.outer-court.com
2
2848
by: hikums | last post by:
how can I use a function inside a function, for example I want to select col1, col2 from table1 where locate(dayofweek(current date),col3) =dayofweek(current date) col3 is a field that contains a string like '12 4567', or '1 4567'. This field specifies what day in the week the job executes, and if there is a match, I want to report col1 and col2.
0
1276
by: sp1dEr | last post by:
Hi all, I have an asp.net application (framework 1.1 sp1) on windows server 2003. When the document root is locate in local that's all ok... but if the document root is locate on locate on network share, application display error message: Server Error in '/MYAPP' Application. --------------------------------------------------------------------------------
2
2234
by: Tim | last post by:
I have placed my assemblies in different folders (as per project req.). I am using config file with <codebase> option and registry with codebase option (COM Interop) to enable the runtime to locate the assemblies. Will I face any problems in future versions due to the usage of 'codebase' option? What precautionary measures need to be taken if the 'codebase' option is used?
7
10994
by: mwt | last post by:
Is there a function in python that does what "locate" does in a bash shell? I know I could do it by using os.popen('locate'), but I'm curious if there's a Python "native" way to go about it. Only needs to work in Unix, but would be interesting if it was cross-platform. Thanks.
2
3073
by: deve8ore | last post by:
Hello, I have built a macro to automatically go to a specific directory and a specific folder, however the names of the files I need to automatically locate change names every month. I.e. - I hit the macro button and I'd like to automatically open a (pdf,xls,doc) file: "C:\Matt\Files\Pricing\Reports\GrossMargin\9279RebateDetail.xls" The only part of the file name that changes every month are the first four numbers before...
3
1886
by: deve8ore | last post by:
Hello, I have built a macro to automatically go to a specific directory and a specific folder, however the names of the files I need to automatically locate change names every month. I.e. - I hit the macro button and I'd like to automatically open a (pdf,xls,doc) file: "C:\Matt\Files\Pricing\Reports\GrossMargin\9279RebateDetail.xls" The only part of the file name that changes every month are the first four numbers before...
0
8991
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
9548
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9374
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9325
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
8244
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
4607
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4876
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2787
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.