473,395 Members | 1,474 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

changing value inside <link> tag

exoskeleton
104 100+
hi dear experts...i dont know if im in the right forum but...if not please kindly move this thread..

my problem is that how to change value like this one:

Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript" type="text/javascript">
  2. <!--
  3. function css_style(css_choice) {
  4.  
  5. document.getElementById("css_style").innerHTML="css_styles/style"+css_choice+".css";
  6.  
  7. }
  8. -->
  9. </script>
  10.  
[HTML]
<link href="<div id=css_style></div>" rel="stylesheet" type="text/css">
[/HTML]

I know this won't work...but i've done this if without that link tag...i can change the value of the div tag ... but what if i would like to place a value inside link tag particularly in the href value? just like the case above...

please help...TIA
Feb 9 '07 #1
6 2232
exoskeleton
104 100+
hi dear experts... i think this is the right forum for this matter..
dear mods please erase my thread at css forum ..thank you
ok..this is my problem..i want to change the value of css through the use of radio button but i will not post everything .. just this particular part...i have 3 radio button on my php page, when i click 1 then it will directly go to this function:

Expand|Select|Wrap|Line Numbers
  1. function css_style(css_choice) {
  2.  
  3. document.getElementById("css_style").innerHTML="css_styles/style"+css_choice+".css";
  4. css_pick="css_styles/style"+css_choice+".css";
  5.  
  6. }
  7. -->
  8. </script>
  9.  
[HTML]
<link href="css_styles/style1.css" rel="stylesheet" type="text/css">
[/HTML]
i try this:
[HTML]
<link href="<div id=css_style></div>" rel="stylesheet" type="text/css">
[/HTML]
but i know it doesn't work but i have to try something...please help

here it work...
[HTML]<div id=css_style></div>[/HTML]

in the <div> tag it works of course..i can see the changeed of results each time i click the radio buttons..but what if i would like to change the value inside <link> particularly the href portion to change the css style...please help me dear experts...

thank you in advance...
Feb 9 '07 #2
dmjpro
2,476 2GB
try to do .......

try{
links = document.getElementsByTag('link')
links[0].attr_name = 'value u want to assign'
}catch(err)
{
alert(err.description);
}

send me the reply ------------- i am online
Feb 9 '07 #3
duye
10
hi dear experts...i dont know if im in the right forum but...if not please kindly move this thread..

my problem is that how to change value like this one:

Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript" type="text/javascript">
  2. <!--
  3. function css_style(css_choice) {
  4.  
  5. document.getElementById("css_style").innerHTML="css_styles/style"+css_choice+".css";
  6.  
  7. }
  8. -->
  9. </script>
  10.  
[HTML]
<link href="<div id=css_style></div>" rel="stylesheet" type="text/css">
[/HTML]

I know this won't work...but i've done this if without that link tag...i can change the value of the div tag ... but what if i would like to place a value inside link tag particularly in the href value? just like the case above...

please help...TIA
try this:
assign your link tag an id.
<link id="YourLinkID" href="" rel="stylesheet" type="text/css">

then in your function:
<script language="JavaScript" type="text/javascript">
<!--
function css_style(css_choice) {
document.getElementById("YourLinkID").setAttribute ("href", "css_styles/style"+css_choice+".css");

}
-->
</script>


but a link is calling the stylesheet by using the URL in href at the time of LOADING, not after the page loaded, so even if you could change the URL in the href on the fly, there is no point to do so, because after you change href's value, the style used by the page does not change.

If you want to change the style on the fly, try thinking some other approaches.

BTW, this POST should be in JAVASCRIPT/AJAX forum, you may get more reply I think.
Feb 9 '07 #4
acoder
16,027 Expert Mod 8TB
Just set an id for the link and change the href:
[HTML]<link id="css_style" href="css_styles/style1.css" rel="stylesheet" type="text/css">[/HTML]
Expand|Select|Wrap|Line Numbers
  1. function css_style(css_choice) {
  2. document.getElementById("css_style").href="css_styles/style"+css_choice+".css";
  3. }
See this page for the <link> DOM.
Feb 9 '07 #5
dmjpro
2,476 2GB
wow!!!!!!!!!!!!!
a new concept i got
lot of thanx

can't i use getElementById('id_name').href = "css_filename_with_path"
instead of using setAttribute.....

one more thing ...

a text box is there .... with id deb_mou

now look at my code .... carefully
document.getElementById('deb_mou').setAttribute('r eadonly') = true
and document.getElementById('deb_mou').readOnly = true

see two readonly spelling is different ..
are two codes work same

i am waiting for ur reply

thanx in advance
Feb 13 '07 #6
exoskeleton
104 100+
try this:
assign your link tag an id.
<link id="YourLinkID" href="" rel="stylesheet" type="text/css">

then in your function:
<script language="JavaScript" type="text/javascript">
<!--
function css_style(css_choice) {
document.getElementById("YourLinkID").setAttribute ("href", "css_styles/style"+css_choice+".css");

}
-->
</script>


but a link is calling the stylesheet by using the URL in href at the time of LOADING, not after the page loaded, so even if you could change the URL in the href on the fly, there is no point to do so, because after you change href's value, the style used by the page does not change.

If you want to change the style on the fly, try thinking some other approaches.

BTW, this POST should be in JAVASCRIPT/AJAX forum, you may get more reply I think.
thank you very much sir Duye...i really appreciate it...more power
Feb 20 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Todd Peterson | last post by:
I'm encountering some wierd behavior with a <link> tag over an HTTPS connection, vs. an HTTP connection... In an ASP/HTML page on my website, I've add a <link rel="shortcut icon"...> in order to...
2
by: Hernán Castelo | last post by:
hi i'm trying to do : <link rel="stylesheet" type="text/css" href="myurl..../inc/css/style.css"/> from the url field of the browser i can normally open the "style.css" with notepad but thru...
2
by: Amir Eshterayeh | last post by:
Dear Friends I want to change the name of my css file dynamically so as Mr. Jos Branders helped me, I can change the <head> tag into an HTML control like this: <head id="myhead" runat="server">...
2
by: brw | last post by:
Is there a way to dynamically add a link tag to the head block of an ..aspx page? I'm aware that you can add a link tag (or literal control) statically and then dynamically modify the attributes....
2
by: Alex Maghen | last post by:
I just learned about the wonderful ~ in paths in ASP.NET which allows me to reference the APPLICATION root instead of the IIS docroot. Love it! I'm finding that I can use ~ in many places as long as...
4
by: Jake Barnes | last post by:
Very odd. Check out this RSS feed that my PHP script just built: http://www.tagcastle.com/rss/photography.xml When I had a straight URL in the <link> tag, or the <comment> tag, then "="...
1
by: Kanon | last post by:
Hi, I hope this is the proper newsgroup for this kind of question. I have just started to learn about RSS and made my first feed: http://www.herbaloutfitters.com/pbw/alpha/rss/1-1.xml Some...
1
by: Baldoni | last post by:
It's been years since putting together a page. This line in my HTML: <link type="text/css" rel="stylesheet" href="net4801style.css"> gives this problem (via weblint HTML checker): attribute...
1
by: Doug.Sheahan | last post by:
I am attempting to parse and xml file using javascript but am running into a problem when parsing a <link></link> pair. For example, the link information in most RSS feeds is given as <link> ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
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...

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.