JavaScript - Css @import And Javascript Question
I have an app in which a CSS file is being imported with:
[code] <style type="text/css" media="all" title="xyz">@import url(assets/css/xyz.css);</style> [/code I have the following function defined: Code: function SetDisplayCSS() { var mysheet=document.styleSheets[0]; var myrules=mysheet.cssRules? mysheet.cssRules: mysheet.rules; alert(mysheet.cssRules); alert(mysheet.rules); alert(mysheet.title); for (i=0; i<myrules.length; i++){ if(myrules[i].selectorText.toLowerCase()=="primarynav"){ //find "a:hover" rule targetrule=myrules[i]; break; } } alert(targetrule); } </script> myrules.length is coming back as 0, even though there are rules defined in xyz.css. Can anyone offer any solutions as to why it's as if no rules are in the css file - is this an issue with @import?? Thanks in advance for any help. Craig Similar TutorialsHey guys so im kind of lost right now. I am trying to import html files directly from a website. How is the best way about doing this? I need to do this over and over again, at least every 2 seconds. My friend said there was a http/https send command or something? Anyone know? Thanks hi guys, I have built an rss ripper, the point is to bypass technology restrictions when exporting from sharepoint to excel 2003. My problem i'm using the code below to output data in a nice html tabular format, however when trying to import into excel via web query i get no data returned, i think this is as it isn't real html, i've made a few alterations and am now getting account pulled back - how do i get it to pull all the data ? code is as follows, also i've put a link at the bottom to w3 so you can get a good idea of the issue: <%@ Language=VBScript %> <html> <head> <script type="text/javascript" src="loadxmldoc.js"></script> </head> <body> <script type="text/javascript"> function loadXMLDoc() { if (window.XMLHttpRequest) { xhttp=new XMLHttpRequest(); } else { xhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xhttp.open("GET","my file path",false); xhttp.send(); return xhttp.responseXML; } xmlDoc=loadXMLDoc(""); uppernum=(xmlDoc.getElementsByTagName( "title" ).length ); accstartnum=2 detstartnum=1 qlow = 0 qhi = 12 //document.write("<table border=1") </script><table border = 1><tr><script> z=xmlDoc.getElementsByTagName("description")[detstartnum] </script><td>Account</td><script> y=z.childNodes[0]; data_dump = (y.nodeValue); data_dump = data_dump.replace(/<div><b>/g,""); data_dump = data_dump.replace(/div>/g,""); data_dump = data_dump.replace(/b>/g,""); data_dump = data_dump.replace(/</g,""); data_dump = data_dump.replace(/\n/g,""); data_dump = data_dump.replace(/\//g,""); data_array = data_dump.split(":"); array_pos = 0 while (array_pos < data_array.length) { if (array_pos%2) { document.write ("<td>" + data_array[array_pos] + "</td>"); array_pos+=1; } else { array_pos+=1; } } document.write("</tr>") while (accstartnum < uppernum) { document.write("<tr>") x=xmlDoc.getElementsByTagName("title")[accstartnum] y=x.childNodes[0]; acc = (y.nodeValue); z=xmlDoc.getElementsByTagName("description")[detstartnum] y=z.childNodes[0]; data_dump = (y.nodeValue); data_dump = data_dump.replace(/<div><b>/g,""); data_dump = data_dump.replace(/div>/g,""); data_dump = data_dump.replace(/b>/g,""); data_dump = data_dump.replace(/</g,""); data_dump = data_dump.replace(/\n/g,""); data_dump = data_dump.replace(/\//g,""); data_array = data_dump.split(":"); array_pos = 1 document.write("<td>" + acc + "</td>") while (array_pos < data_array.length) { if (array_pos%2) { array_pos+=1; } else { document.write ("<td>" + data_array[array_pos] + "</td>") array_pos+=1; } } accstartnum+=1; detstartnum+=1; document.write("</tr>") } </script></table><script> //url = document.location.href; //urll = url.split("?"); //if (urll.length == 0) // { // document.self.location.replace("http://midevsso.gcf-uk.gcf.capital.ge.com/Development/rssreader.asp?reload=1"); // } </script> </body> </html> if you have excel 2003 you can get an idea of the issue by trying to import the table he http://www.w3schools.com/XML/tryit.a..._display_table I have an application that has a menu - one of the choices on that menu is "Contacts" - This menu is controlled by css - I've written a script that will modify the css style setting for "display" and "zindex" for the rule that controls the pull down for contacts - this worked for hover, but I am now trying to change to a click event - I successfully change the rule, but the menu doesn't display - not sure if I'm returning incorrectly form the javascript function or what - here's a code snippet: CSS: Code: .primaryNav .subMenu { background-color: #B0967E; position: absolute; width: 300px; left: 600px; /* 823px - 300px - 20 px + 97px */ padding: 10px; display: none; color: #fff; font-size: 90%; } Javascript: Code: <script type="text/javascript"> function SetDisplayCSS() { var mysheet=document.styleSheets[0]; var myrules=mysheet.cssRules? mysheet.cssRules[0].styleSheet.cssRules: mysheet.imports[0].rules; for (i=0; i<myrules.length; i++){ if(myrules[i].selectorText.toLowerCase()==".primarynav .submenu"){ //find "a:hover" rule targetrule=myrules[i]; alert("Rule is found"); break; } } targetrule.style.display = "block"; targetrule.style.zindex = "10"; alert(targetrule.selectorText); alert(targetrule.style.backgroundColor); alert(targetrule.style.position); alert(targetrule.style.width); alert(targetrule.style.left); alert(targetrule.style.padding); alert(targetrule.style.display); alert(targetrule.style.color); alert(targetrule.style.fontSize); alert(targetrule.style.zindex); return true; } </script> html Code (names have been changed to protect the innocent) - note the onclick event handler for the contacts menu option. Code: <li class="pn test"><a href="#" onclick="return SetDisplayCSS();" name="contacts">Contacts</a> <div class="subMenu"> <table width="100%"> <tbody> <col /> <col align="right" valign="top" /> <tr> <td><a href="mailto:abc@xxxxxxx.com">Service Requests</a></td> <td>555.555.5555</td> </tr> <tr> <td><a href="mailto:me@notreal.com">Bugs Bunny</a><br />Tenant Liaison</td> <td>555.555.555</td> </tr> <tr> <td><a href="mailto:blah@blah.com">blah blah</a><br />Client Services Manager</td> <td>123.456.1234</td> </tr> </tbody> </table> <p><a href="xxxxxxxx.htm" class="more">More Contacts...</a></p> </div> </li> Thanks for any help...... I am a newbie with a newbie question =) I recently took an exam type thing using my Firefox browser (v3.5.3). I still have my browser window open that I used, and when I press the back button on the browser I get a message "To display this page, Firefox must send information that will repeat any action ..." Is there any way (either disk or memory cache) to reload the pages with out having to resend the data, OR is there any way (hex editor) to view the exam (forms) questions?? Just curious, Thanks I'm not really looking for someone to fix/answer this for me, but maybe give me a hit in the right direction. I need to fix this while loop to run correctly, but has errors in the code. This code is supposed to fill an array with numbers 1 through 100 and then print them. Here is the code: <script type="text/javascript"> /* <![CDATA[ */ var count = 0; var numbers = new Array(100); while (count < 100) { numbers[count] = count; ++count; } while (count < 100 ) { document.write(numbers[count]); ++count; } /* ]]> */ </script> What i am most confused about is this part of the code numbers[count] i don't understand what is going on there. Sorry i am very new to this. Any ideas would be appreciated thank you. So erm. Hello there. I fail at javascript, and yet, I'm trying it. Anyways, I'm working on this thing. It's an extension for google chrome very similar to firefox plugins and so on. I'm making an extension so that, when installed, it changes the look of facebook completely. I have successfully changed the colors. However, I am having some trouble getting my javascript to change images. If anybody out there has some insight on what I'm doing wrong, I am glad to accept any kind of help that anyone is willing to give me, lol. What I've done so far: I have to change the facebook logo (what I'm trying to do now) and then change the links, and very few more things, and I'm done. Problem: I can't figure out how to change the image. I can change the background color, as you saw earlier. I just need a code to change the image. The CSS behind it is: Code: #pageLogo a{background:#3b5998 url(/rsrc.php/z8S5R/hash/ez3x5cuc.png) no-repeat -21px 0;display:block;position:absolute;height:31px;left:-6px;width:103px;top:10px} and the HTML implementing it is: Code: <h1 id="pageLogo"><a href="http://www.facebook.com/?ref=logo" title="Home" accesskey="1"></a></h1> and my structure of javascript is: Code: for(i=0;i<=document.getElementsByTagName("div").length;i++) { if(document.getElementsByTagName("div")[i].id != null) { if((document.getElementsByTagName("div")[i].id=="blueBar")) { document.getElementsByTagName("div")[i].style.backgroundColor='#B22222'; } if(( document.getElementsByTagName("div")[i].id == "headNavOut")) { document.getElementsByTagName("div")[i].style.backgroundColor='#8B0000'; } } } }); I appreciate any help anyone's willing to give. I think this is a pretty easy to fix error made by a newb ( me. Can anyone tell me why the call to "this.slideNext() " in the code below does not work. Apparently "this.slideNext() " is not a function? Code: function ScoopAnimation(_path, _start, _end, _delay){ this.start = _start this.end = _end; this.delay = _delay; this.path = _path this.currentFrame = _start; this.slideNext() = function (){ this.currentFrame ++; console.log(' next this.currentFrame : ' +this.currentFrame ); } this.start= function () { console.log('next this.start() : ' +this.currentFrame ); //THE NEXT LINE CAUSES THE ERROR! this.slideNext() } this.start(); } Hey Guys, I was creating an image map with rollover images. I was just wondering if I could add a fade effect to the transition. The underarms is the only rollover that works at the moment. Please check the source code for the code because it's too long to post here. http://wedezign.com/chris/ I'm trying to figure out this question that was assigned to me, as I haven't done alot on javascript before but I've tried to get most of this, I'm just not sure if this is correct. If anybody could help it would be greatly appreciated. The question is as follows: You are provided with a string array called country that contains the name of every country that the Ski Club visits. For example one element of this array might be as follows: country[0] = "Austria" Another array called villages contains strings with information on village names and altitude in a particular country. For example: villages[0] = "Austria:Seefield 850m*"; Write a JavaScript function snowReport(countryIndex) that will use the arrays provided to write a report of all villages that include a given country. The function will be passed an integer representing the index of an element of the country array. A match is found if the country appears in a string (Hint use appropriate JavaScript function to evaluate if a country name is contained in a village string.) All matching villages should be displayed. Output should be displayed in the villages div element you defined in part (a). Output is shown for a search for Austria in Figure 1b. <script type="text/javascript"> function makeArray() { var country = new Array(5); country[0] = "Austria"; country[1] = "Canada"; country[2] = "France"; country[3] = "Germany"; country[4] = "Switzerland"; return country; var villages = new Array(2); villages[0] = "Austria:Seefield 850m*"; villages[1] = "Austria:Ellam 100m"; return villages; } function snowReport(countryIndex){ var string = ""; for (var i = 0; i < countryIndex.length; i++){ str += countryIndex[i] + " "; } return str; } </script> </head> <body> <script> var x = makeArray(); document.write(snowReport(x)); </script> </body> </html> Many thanks! HI Guys!! My name is Megan and I am a college student in need of some JavaScript help for my computer science class!! My professor is making us complete some stupid class project for finals and I can't figure it out! He suggested that we may try to find a JavaScript Website to help us if we have trouble figuring out how to write the code. I have looked and looked and can't find out how to fix my code!! We have to write code to make a slot machine .. I have started the code based on what he gave us and have tried my hardest to figure out how to complete it but I do not know how to finish it. I have the images working correctly (kind of.. the second one seems to have problems loading? I dunno what I did to mess that up) and the counter working, but I need to make it add 13 credits when all 3 images are the same. I added code that I thought would work but it's not for some reason that I can't figure out. It should also pop up an alert screen when all 3 are correct and you win. I guess this would have to be including with the if statement and something like alert('You win 12 credits!!!') Lastly I need to add code that prevents the person from playing when the credit line is 0 (so you can't get - credits!) and I have no idea how to do this. Any help would be greatly appreciated! Here's what I have so far! HI Guys!! My name is Megan and I am a college student in need of some JavaScript help for my computer science class!! My professor is making us complete some stupid class project for finals and I can't figure it out! He suggested that we may try to find a JavaScript Website to help us if we have trouble figuring out how to write the code. I have looked and looked and can't find out how to fix my code!! We have to write code to make a slot machine .. I have started the code based on what he gave us and have tried my hardest to figure out how to complete it but I do not know how to finish it. I have the images working correctly (kind of.. the second one seems to have problems loading? I dunno what I did to mess that up) and the counter working, but I need to make it add 13 credits when all 3 images are the same. I added code that I thought would work but it's not for some reason that I can't figure out. It should also pop up an alert screen when all 3 are correct and you win. I guess this would have to be including with the if statement and something like alert('You win 12 credits!!!') Lastly I need to add code that prevents the person from playing when the credit line is 0 (so you can't get - credits!) and I have no idea how to do this. Any help would be greatly appreciated! Here's what I have so far! Code: <html> <head> <title> Slot Machine</title> <script type="text/javascript" src="http://balance3e.com/random.js"></script> <script type="text/javascript"> function SpinSlots() // Assumes: slot images are in http://balance3e.com/Images // Resultes: displays 3 random slot images { var slot1, slot2, slot3; slot1 = RandomOneOf(['lemon', 'cherry', 'bar']); slot2 = RandomOneOf(['lemon', 'cherry', 'bar']); slot3 = RandomOneOf(['lemon', 'cherry', 'bar']); document.getElementById('slot1Img').src = 'http://balance3e.com/Images/' + slot1 + '.jpg'; document.getElementById('slot2Img').src = 'http://balance3e.com/Images/' + slot2 + '.jgp'; document.getElementById('slot3Img').src = 'http://balance3e.com/Images/' + slot3 + '.jpg'; document.getElementById('credits').innerHTML = parseFloat(document.getElementById('credits').innerHTML) - 1; if (slot1 == slot2 == slot3) { document.getElementById('credits').innerHTML = parseFloat(document.getElementById('credits').innerHTML) + 13; } } </script> </head> <body> <div style="text-align:center"> <p> <img id="slot1Img" border=1 alt="slot image" src="http://balance3e.com/Images/cherry.jpg"> <img id="slot2Img" border=1 alt="slot image" src="http://balance3e.com/Images/lemon.jpg"> <img id="slot3Img" border=1 alt="slot image" src="http://balance3e.com/Images/bar.jpg"> </p> <input type="button" value="Click to Spin" onclick="SpinSlots();"> <p> Credits Remaining: <spin id="credits">20</span> </p> </div> </body> </html> I have a question about Javascript. Hello. I need help with JavaScript enabled. My job so that I can automatically send button to be pushed faster. I use google chrome. For example; Automatically have form filling add-ons. (Autofill), but only to fill the send button will not print. How can I do this automatically? Button codes; <input type='submit' name='post_shout' value='Shout' class='button' /> Google Chrome address bar: javascript: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx what I need to write here? Can I do it after 1-2 seconds and fill out? Many thanks in advance. (My English is poor) I have done a basic while loop code but I can not figure out how to make the output print in 4 lines containing 5 numbers each. Can anyone tell me how to specify the number of output that appears on each line? Code: <?xml version="1.0" encoding="UTF-8"?> <!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> <title>example</title> </head> <body> <script type="text/javascript"> <!-- var x = 1; var linebreak="<br/>" while (x <= 20) { document.writeln("" + x + " " + ""); x = x + 1; } // --> </script> </body> </html> Hi, I have a form with a input field(name) and a textarea(keywords). I am using the below code to sync the value of name with keywords. If additional keywords are added in the textarea and then the name field is altered all additional keywords are lost as they are overwritten by the name field sync. I would like to place a comma after the synced value and have whatever follows the comma to not be touched. Like this: Name: keyword1 Keywords: keyword1, keyword2, keyword3, etc. Could anyone point me in the right direction? Any help with this would be most appreciated. Code: var obj=document.getElementById('name'); var att = {"onkeyup":"sync()"}; for(var n in att) { obj.setAttribute(n, att[n]); } function sync() { var v1 = document.getElementById('name'); var v2 = document.getElementById('keywords'); v2.value = v1.value; } Hello, posted this on dynamicdrive.com with no response, so I am trying this forum. I have been assigned to build a content locator. We cannot use a database and all content needs to load from same page. Based on my boss' design and client needs, this is what I came up with: http://contentx.com/content_locator/ I am using a Dynamic Drive script to power the dropdown and content underneath the drop down, http://contentx.com/content_locator/js/dd_cx_script.js and using a JQuery script to change the content in the window to the right. http://contentx.com/content_locator/...s_cx_script.js My questions a 1) Is there a better method to do this? (stupid question I know... of course there is!!) I would like it to be as simple as possible, no animation needed. Just need to have content from the DIV on the right side load content in the Main body div on the left (the box) 2)Is it possible to change the content on the right side when you select an option from the drop down? (say I select <option>Free Campaigns</option> I want the content to change on the right to match one of the free campagins) 3)Finally, my margins in IE 7 are all over the map, looks great in all other browsers, but in IE my TABS (colored green and blue) are about 10pixels up to high, and my belowcontent div on the left has a top margin of 12px below the dropdown... Thanks for any help, zack Hi, I have a parent form and a child form.. I have a checkboxlist in my child form. Users can select multiple values from checkbox list and on clicking button i want to pass selected values to parent form. Below is my code which works fine for passing value from child form to parent form (for the value entered in textbox) by clicking on button in child form textbox value is passed to parent form and child form closes, but how to pass multiple selected values from child to parent form. child Form: Code: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here Dim scr As String = "<script language=javascript> function Done() { var lName=document.getElementById('txt_division').value; var ret= new Array(lName); window.opener.update(ret); window.close();}</script>" Page.RegisterClientScriptBlock("done", scr) End Sub Thanks to help with code / refer articles. Hello to everyone, I got a bit of a situation here, I wrote this code that basicaly what it does is, gets code from input field, sends it to php file get the results back and also calls the second php page to chage the prices but kill me I cant figure out what I did wrong Can anyone help? Here is the code: <div style = "position: relative; width: 100%; height: 100%;" id = "idCouponRequest"> <table width="100%" border="0" cellspacing="4" cellpadding="4" id = "tblCoupon"> <tr> <td class="detHeadTxt" align="right" valign="middle">Enter Your Coupon:</td> <td width="165" align="center" valign="middle"><input id = "edtCoupon" type="text" name="coupon" size="32" maxlength="15"></td> <td width="175" align="right" valign="middle"><INPUT type="image" name="coupon" src="images/redeem.gif" class = "mnCurs" border="0" onclick = "javascriptostCheckout();"></td> </tr> </table> </div> <script language = "javascript"> var couponCode; function postCheckout() { getContent('includes/checkout/processCoupon.php', 'coupon_code=' + document.getElementById('edtCoupon').value, function () { couponCode = document.getElementById('edtCoupon').value; var win = document.getElementById('idCouponRequest'); win.innerHTML = '<table border = 0 width = 100% height = 100%><tr><td align = center valign = center class = \"detCartHead\">Processing Coupon...</td></tr><tr><td align = center valign = center><img src="images/rating_loading.gif" alt="loading" /></td></tr></table>'; }, function () { if (xmlHttp.readyState != 4) return; var res = xmlHttp.responseText; var win = document.getElementById('idCouponRequest'); win.innerHTML = res; refreshOrderSumm(); }); } function refreshOrderSumm() { getContent('includes/checkout/processOrderSumm.php', 'coupon_code=' + couponCode, function () { var win = document.getElementById('divSummLoading'); win.style.display = ''; }, function () { if (xmlHttp.readyState != 4) return; var res = xmlHttp.responseText; var win = document.getElementById('divSummLoading'); win.style.display = 'none'; var win = document.getElementById('divCouponSumm'); win.innerHTML = res; }); } </script> I put the jquery script into my subdirectory. In the header which one is correct: Code: <script type="text/javascript" src="../jquery/jquery.js"></script> or Code: <script src="../jquery/jquery.js"></script> And there is this code: do I put this in the body and enclose it with the <script>tag? Code: $(function(){ // set interval for 5 minutes setInterval(function(){ $.ajax({url: "keep-alive.php"}); }, 300000); }); Hi, I am just beginning out with Javascript and trying to complete a simple login page. Clicking on the Login button should bring up a message 'Access authorised' or 'Access denied' in the 'output' div of the page. Unfortunately only 'Access Denied' displays, even if the password entered is correct. There are no messages displayed in the Error Console. Any advice greatly appreciated! Code: <html> <head> <title>Function Example</title> <script language="javascript" type="text/javascript"> function isAccessAuthorised(enteredPassword) { var result; if(enteredPassword=="password") { result=true; } else { result=false; } return result; } function buttonClicked() { var isAuthorised = isAccessAuthorised("enteredPassword").value; if(isAuthorised==true) { document.getElementById("output").innerHTML=<p>Access authorised</p>; } else { document.getElementById("output").innerHTML=<p>Access denied</p>; } } </script> </head> <body> <form> <input type="text" id="username" /> <br/> <input type="text" id="enteredPassword" /> <br/> <input type="button" onClick="buttonClicked()" value="Login"> </form> <div id="output"> </div> </body> </html> I need help in writing the commands that calls the function product 5 times (for loop). function product multiplies two variables (a*b) where a, and b are entered by the user using two prompt boxes and check. (using if else) a. if the result is greater than 10 return "Greater" b. if the result is even return "Even" in heading 1 style. c. else return "try again" in heading 1 style. Reply With Quote 01-17-2015, 11:37 AM #2 xelawho View Profile View Forum Posts Senior Coder Join Date Nov 2010 Posts 3,043 Thanks 56 Thanked 568 Times in 565 Posts Two questions: - When is your homework due? - What have you done so far? Reply With Quote 01-17-2015, 11:41 AM #3 1x1x1x1 View Profile View Forum Posts New to the CF scene Join Date Jan 2015 Posts 3 Thanks 0 Thanked 0 Times in 0 Posts Originally Posted by xelawho Two questions: - When is your homework due? - What have you done so far? I know how to declare the function and use for loop, I just don't understand how to use if else with return. Reply With Quote 01-17-2015, 11:52 AM #4 1x1x1x1 View Profile View Forum Posts New to the CF scene Join Date Jan 2015 Posts 3 Thanks 0 Thanked 0 Times in 0 Posts This is what I know so far, PLEASE CORRECT ME IF I AM WRONG! <html> <head> <script type=text/javascript> function product(a,b) { return a*b; } </script> </head> <body> <script type=text/js> for(i=0;i<5;i++) { var x=prompt("Enter number") var y=prompt("Enter number") document.write(product(x,y)) please correct me if i am wrong, and please help me with return :/ Reply With Quote 01-17-2015, 12:06 PM #5 TiredPerson View Profile View Forum Posts New to the CF scene Join Date Jan 2015 Posts 7 Thanks 0 Thanked 0 Times in 0 Posts Read about return in Tryit Editor v2.3 One way is to write a <p id="ape"> try again</p> in html and in script write a var which gets the "ape" id from your html. var ape= document.getElementById("ape").innerHTML Code: if(2>1){ return ape; }else if(3==3){ return myOtherVariable; } Reply With Quote 01-17-2015, 12:16 PM #6 xelawho View Profile View Forum Posts Senior Coder Join Date Nov 2010 Posts 3,043 Thanks 56 Thanked 568 Times in 565 Posts Originally Posted by 1x1x1x1 <script type=text/js> I'd be looking at that line first if I were you Reply With Quote 01-19-2015, 05:46 AM #7 Old Pedant View Profile View Forum Posts Supreme Master coder! Join Date Feb 2009 Posts 28,311 Thanks 82 Thanked 4,754 Times in 4,716 Posts And why do you need an return other than what you used already in the product( ) function? (For that matter, why in the world do you need or want the product( ) function???) |