JavaScript - Can't Get My Webpage Validated Due To Javascript
I'm trying getting one of my webpage XHTML 1.0 Strict.
There is only one error left, namely: document type does not allow element "br" here at this line: Code: container.innerHTML = result.translation.replace(/mdw/g, '<br />'); Obviously this is part of my javascript coding, but it's where the validation goes wrong. I can't put the javascript in an external file since several javascript variables are getting filled by php. I've tried several options, but I ain't a javascript expert.. so perhaps someone can help me out. Similar TutorialsComplete and utter newb here, so I apologize in advance. I'm trying to create a widget for a website that will show the Recent Comments, but will limit what is shown to 1 comment per unique thread. The idea being that the popular threads don't drown out the unpopular threads in the widget. Alas, I do not know Javascript. I am, however, proficient in XSLT. So I mapped out a little transform to get (essentially) what I want, thus: Input: http://anamardoll.disqus.com/latest.rss XSLT: Code: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template name="RSS_Feed" match="rss"> <xsl:value-of select="'
'"/> <!-- ITERATE THROUGH ALL POST NODES --> <xsl:for-each select="//item"> <!-- IF NOT PREVIOUSLY USED --> <xsl:if test="not(preceding-sibling::item/child::title/node() = current()/child::title/node())"> <xsl:value-of xmlns:dc="http://purl.org/dc/elements/1.1/" select="child::dc:creator/node()"/> <xsl:value-of select="(' posted on 
')"/> <xsl:value-of select="substring-after(child::title/node(), 'Ramblings: ')"/> <xsl:value-of select="('
')"/> <xsl:value-of select="child::link/node()"/> <xsl:value-of select="('

')"/> </xsl:if> </xsl:for-each> </xsl:template> </xsl:stylesheet> Output: Code: Ana Mardoll posted on Twilight: It's All About The Protagonist, Baby http://www.anamardoll.com/2011/09/twilight-its-all-about-protagonist-baby.html#comment-320798527 Thepepboy posted on eReader: Running CM7 on a Nook Color from SD Card (REPOST) http://www.anamardoll.com/2011/07/ereader-running-cm7-on-nook-color-from.html#comment-320690496 Jckeeml posted on Narnia: The Clean and Tidy Poor http://www.anamardoll.com/2011/09/narnia-clean-and-tidy-poor.html#comment-320649311 chris the cynic posted on Metapost: Newsletter Subscriptions http://www.anamardoll.com/2011/09/metapost-newsletter-subscriptions.html#comment-320586205 (And here is why I say the output is "essentially" what I want -- I'd PREFER the links to be linked around the preceding texts, but that's an advanced step at this point in the game.) Is there an easy way in Javascript to just invoke an XSLT on a webpage and display the results? I've read online that there is, but can find no examples that work for me. I do appreciate any help provided and thank you in advance! (Also, for background: This will be going into the Blogger HTML/Javascript Widget tool, so... yeah.) Hi All, This is my first post and I need some assistance. I'm learning code and attempting to put more than 1 script on a webpage, but individual (separate pages) but together, neither one works. I'm a newbie and my professor doesn't know how to teach so it's me trying to do this myself and any assistance will be helpful. This is what I have (trying to add random pictures and a cycling banner) <script> var imgArray = new Array (4); var index = 0; function cycle () { document.banner.src = imgArray[index].src; index++; if (index > 3) { index = 0; } setTimeout("cycle()", 2000); return; } function startup () { imgArray[0] = new Image; imgArray[0].src = "Im.png"; imgArray[1] = new Image; imgArray[1].src = "Tired.jpg"; imgArray[2] = new Image; imgArray[2].src = "of this.jpg"; imgArray[3] = new Image; imgArray[3].src = "Rainy.jpg"; cycle(); return; } </script> </head> <body onLoad="select();startup()"> <div align="center"> <img name="banner" src="Im.png"> </div> </body> </body> <script> var imgArray = new Array (5); var index = 0; function select () { index= Math.floor(Math.random() * 5); document.banner.src = imgArray[index].src; setTimeout("select()", 2000); return; } function startup () { imgArray[0] = new Image; imgArray[0].src = "1.jpg"; imgArray[1] = new Image; imgArray[1].src = "2.jpg"; imgArray[2] = new Image; imgArray[2].src = "3.jpg"; imgArray[3] = new Image; imgArray[3].src = "4.jpg"; imgArray[4] = new Image; imgArray[4].src = "sheep.jpg"; select(); return; } </script> </head> <body onLoad="cycle(); startup()"> <div align="center"> <img name="banner" src="1.jpg"> </div> </body> OK, I programmed most of my page, but not all of it, not the CSS or Javascript. On all the individual HTML pages, it shows Done but with errors. Here is the error. Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; InfoPath.2; Alexa Toolbar) Timestamp: Sat, 18 Dec 2010 05:18:55 UTC Message: Invalid argument. Line: 4 Char: 116 Code: 0 URI: http://www.addyourl.com/convergance/nym6pbs.js Now, the addyourl site is mine too and I put it there because I want my page to load quicker and everything that I do to make it load quicker suggest combing CSS sheets and Javascript files, but whatever the case, I don't have the technical ability to do that. My webpage is: www.fkcapitalfund.com So, I can't fix that error, I don't have the technial wherewithal to do it and the person who did the programming won't help anymore, he made the template for me and left me to my own devices unfortunately. Along the same lines as this, my goal is to get my page to load quicker and my appealing to google Any help to that end would be appreciated. Thanks Alright so I've been teaching myself php/javascript/html/joomla for the past couple weeks, learning as i go along. So bear with me if i seem like a total moron =p. I'm trying to run a script from a js file to add javascript to the website inside the iframe. I also would like the script to only be activated onclick(this is all in an article). To clarify my website has an iframe and this iframe contains a webpage from http://website987.com/. I want to run thescript.js on the website inside that iframe, to add javascript to that website, however i also only want to run this js file on the click of a link/button. I hope i'm being clear if I'm not please tell me and ill try to reiterate. I've been trying to get this to work for a while now and I feel like this is really simple and I'm asking a stupid question. However this is what I've got so far, currently this just redirects the iframe to the URL with my code on it(instead of actually running it).How could i edit this/what coding could I use to make it so thescript.js actually runs instead of it being just redirected? Reply With Quote Code: <?php $filename = 'thescript.js'; $path = '/media/system/js/'; // add the path parameter if the path is different than : 'media/system/js/' JHTML::script($filename, $path, true); // MooTools will load if it is not already loaded ?> Code: <HTML> <HEAD> <script language="javascript"> function loadOne() { parent.FRAME1.location.javascript: function('/media/system/js/thescript.js') } </script> </HEAD> <BODY> <iframe name="FRAME1" src="http://website987.com/" width="740" height="500" frameborder="0" scrolling="yes"></iframe> <a href="javascript:loadOne()">Click Here/a> </BODY> </HTML> Am i even on the right track? I've been testing out a billion different codes and I think it would be ridiculous to post them all so I was hoping someone could help me fix this code or at least point me in the right direction. I'm usually able to figure everything out on my own but I'm failing atm and I just need help on this one thing, I would be ever so thankful for any assistance provided, ! (BTW I'm also currently using the Joomla CMS and a joomla plugin called CodeMirror that runs your code directly from the article, not sure if this is relevent or not) I have a JavaScript drop down menu and just under it is the slide show also using JavaScript.Now when I you select the menu the drop down contents are hidden behind the slide underneath it .But if it is a still image,they appear on top of the image. I need the menu the drop down contents to appear on top on the slide show. How can I achieve that. Hi. Can someone tell me if it is possible to display the duration a webpage is accesssed. For example, if its a form webpage, then the time to be displayed will be = time the webpage was left (press submit button etc. or the time the viewer left the page) - time the webpage was first accessed or loaded. If it is possible with javascript, what are the methods, attributes etc that need to be used. How do you make an ios5 type notification system with javascript for your webpage?
Can someone please show me a working example of how to load a WebPage from an existing WebPage using Javascript! I have tried googling the syntax and not having any luck. Thanks, Blake Hi please help me with this website. This website is used to list 6 events and then it should accurately countdown to when that event happens. As it is right now it accurately counts days, but hours, minutes, and seconds are counted down incorrectly. Here is the js file: /* New Perspectives on JavaScript, 2nd Edition Tutorial 2 Review Assignment Author: Andrew Duren Date: 8 May 2011 Function List: showDateTime(time) Returns the date in a text string formatted as: mm/dd/yyyy at hh:mm:ss am changeYear(today, holiday) Changes the year value of the holiday object to point to the next year if it has already occurred in the present year countdown(stop, start) Displays the time between the stop and start date objects in the text format: dd days, hh hrs, mm mins, ss secs */ function showDateTime(time) { date = time.getDate(); month = time.getMonth()+1; year = time.getFullYear(); second = time.getSeconds(); minute = time.getMinutes(); hour = time.getHours(); ampm = (hour < 12) ? " a.m." : " p.m."; hour = (hour > 12) ? hour - 12 : hour; hour = (hour == 0) ? 12 : hour; minute = minute < 10 ? "0"+minute : minute; second = second < 10 ? "0"+second : second; return month+"/"+date +"/"+year+" at "+hour+":"+minute+":"+second+ampm; } function changeYear(today, holiday) { var year = today.getFullYear(); holiday.setFullYear(year); year = (today > holiday) ? year + 1 : year; year = holiday.setFullYear(year); } function countdown(start, stop){ time = stop - start; var rawdays = ((time)/(1000*60*60*24)); days = Math.floor(rawdays); //milisec/sec*sec/min*mins/hour*hours/day is what's divided 4 value var rawhours = ((rawdays - days)*24) - 1; hours = Math.floor(rawhours); var rawminutes = (rawhours - hours)*60; minutes = Math.floor(rawminutes); var rawseconds = ((rawminutes - minutes)*60) + 1; seconds = Math.floor(rawseconds); return days + " days, " + hours + " hours, " + minutes + " mins, " + seconds + " secs"; } Here is the html file: <?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> <!-- New Perspectives on JavaScript, 2nd Edition Tutorial 2 Review Assignment Events in Tulsa Author: Andrew Duren Date: 08 May 2011 Filename: events.htm Supporting files: dates.js, logo.jpg, tulsa.css --> <title>Upcoming Events at Tulsa</title> <link href="tulsa.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="dates.js"></script> <script type = "text/javascript"> function timeLeft() { //the today variable contains the current date and time var today = new Date(); var Date1 = new Date("January 14, 2011 10:00:00"); var Date2 = new Date("May 21, 2011 12:00:00"); var Date3 = new Date("July 4, 2011 9:00:00"); var Date4 = new Date("September 1, 2011 12:00:00"); var Date5 = new Date("December 1, 2011 11:30:00"); var Date6 = new Date("December 31, 2011 3:30:00"); //Display the current date and time. document.eventform.thisDay.value = showDateTime(today); changeYear(today, Date1); changeYear(today, Date2); changeYear(today, Date3); changeYear(today, Date4); changeYear(today, Date5); changeYear(today, Date6); document.eventform.count1.value = countdown(today, Date1); document.eventform.count2.value = countdown(today, Date2); document.eventform.count3.value = countdown(today, Date3); document.eventform.count4.value = countdown(today, Date4); document.eventform.count5.value = countdown(today, Date5); document.eventform.count6.value = countdown(today, Date6); } </script> </head> <body onload="setInterval('timeLeft()', 1000)"> <form name="eventform" id="eventform" action=""> <div id="logo"> <img src="logo.jpg" alt="Tulsa Events" /> </div> <div id="links"> <a href="#">Home</a> <a href="#">City Services</a> <a href="#">City Agencies</a> <a href="#">Mayor's Office</a> <a href="#">News Today</a> <a href="#">Upcoming Events</a> <a href="#">Site Map</a> <a href="#">Search Engine</a> <a href="#">Public Notices</a> <a href="#">Survey Form</a> <a href="#">Contact Us</a> <a href="#">E-Government</a> </div> <div id="main"> <h3>Countdown to Upcoming Events</h3> <table> <tr> <th colspan="2" style="text-align: right">Current Date and Time</th> <td><input name="thisDay" id="thisDay" readonly="readonly" size="40" /></td> </tr> <tr> <th>Event</th> <th>Starting Time</th> <th>Countdown to Event</th> </tr> <tr> <td><input value="Heritage Day" readonly="readonly" size="20" /></td> <td><input value="Jan 14 at 10:00 a.m." readonly="readonly" size="20" /></td> <td><input name="count1" id="count1" size="40" /></td> </tr> <tr> <td><input value="Spring Day Rally" readonly="readonly" size="20" /></td> <td><input value="May 21 at 12:00 p.m." readonly="readonly" size="20" /></td> <td><input name="count2" id="count2" size="40" /></td> </tr> <tr> <td><input value="July 4th Fireworks" readonly="readonly" size="20" /></td> <td><input value="Jul 4 at 9:00 p.m." readonly="readonly" size="20" /></td> <td><input name="count3" id="count3" size="40" /></td> </tr> <tr> <td><input value="Summer Bash" readonly="readonly" size="20" /></td> <td><input value="Sep 1 at 12:00 p.m." readonly="readonly" size="20" /></td> <td><input name="count4" id="count4" size="40" /></td> </tr><tr> <td><input value="Holiday Party" readonly="readonly" size="20" /></td> <td><input value="Dec 1 at 11:30 a.m." readonly="readonly" size="20" /></td> <td><input name="count5" id="count5" size="40" /></td> </tr> <tr> <td><input value="New Year's Bash" readonly="readonly" size="20" /></td> <td><input value="Dec 31 at 3:30 p.m." readonly="readonly" size="20" /></td> <td><input name="count6" id="count6" size="40" /></td> </tr> </table> </div> </form> </body> </html> Please tell me what I need to do to make all of them countdown properly and tell me what technique I can use in the future to do this for future websites in case I need to countdown to 30 events. I would appreciate any help. Hello all, I'm trying to open up an internal link from my leftnav div into my content div. I used the following JS code from my book but im not quite sure how to make it all work. Any thoughts appreciated. Thank you Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <!--header script starts here --> <script type="text/javascript"> window.onload = initlinks; function initlinks() { for (var i = 0; i < document.links.length; i++) { document.links[i].onclick = setContent; } } function setContent() { document.getElementById("content").contentWindow.document.location.href = this.href; return false; } </script> <style type="text/css"> html, body { margin: 0; padding: 0; } #container { width: 90%; margin: 10px auto; background-color: #fff; color: #333; border: 1px solid gray; line-height: 130%; } #header { height: 60px; background-color: #ddd; border-bottom: 1px solid gray; } #leftnav { float: left; width: 160px; height: 380px; margin: 0; padding: 1em; } #content { margin-left: 200px; border-left: 1px solid gray; padding: 1em; height: 380px; } </style> <title>JavaScript</title> </head> <body> <div id="container"> <div id="header"> <h1>JavaScript</h1> </div> <div id="leftnav"> <p> <a href='#'>Load Content</a> <br /><br /> <a href='#'>Load Content</a> <br /><br /> <a href='#'>Load Content</a> <br /><br /> <a href='#'>Load Content</a> <br /><br /> <a href='#'>Load Content</a> <br /><br /> </p> </div> <!--Div to load content into--> <div id="content"> <h2>Subheading</h2> <p> Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel erat volutpat. </p> </div> </div> </body> </html> Hi, I'd like to insert a date on a webpage in the following format: Monday, May 10, 2010 However, I want to be able to set the date 6 days before the current date. So, if today's date is Monday, May 10, 2010, I want it to instead display the following: Tuesday, May 4, 2010 Can someone please provide me the javascript and html coding to be able to do this? I'd seriously appreciate it. Thanks much in advance!! Hi, I would like to ask if there is anyway to get a variable from any webpage source using javascript. Something like javascript: document.getelement? Hi, I need an option to help my family members who does not have computer knowlege in logging onto a online TV channel website. Can you please let us know how to write a script which will open the web page and automatically login with the user id and password. webpage is http://www.yupptv.com/ Thanks in Advance for the help. Regards, scrptlng I went to the PHP section of this site and posted this same question, but someone told me it's a javascript question. I'm trying to carry a string from one webpage to another. The user inputs some data on page 1, the info gets tested for certain elements, then gets sent to page 2. The problem is the strings aren't transferring and I don't know how to use sessions to transfer them. I need recipeNameEl, ingredientsEl, and descriptionsEl to be stored to a string and then transferred to the page the form's action="" attribute points to. How can I accomplish this? Code: <script> function checkFields() { var recipeNameEl = document.getElementById( 'recipeName' ); var ingredientsEl = document.getElementById( 'ingredients' ); var descriptionEl = document.getElementById( 'description' ); var helperMsg1 = 'You have not filled in all required fields.'; var helperMsg2 = 'I thought I said no measurements! (No Numbers)'; return notEmpty( recipeNameEl, ingredientsEl, descriptionEl, helperMsg1, helperMsg2 ); } </script> <script type="text/javascript"> function notEmpty( recipeNameEl, ingredientsEl, descriptionEl, helperMsg1, helperMsg2 ){ if(recipeNameEl.value.length == 0){ alert(helperMsg1); recipeNameEl.focus(); return false;} if(ingredientsEl.value.length == 0){ alert(helperMsg1); ingredientsEl.focus(); return false;} if(descriptionEl.value.length == 0){ alert(helperMsg1); descriptionEl.focus(); return false;} var alphaExp = /^[a-zA-Z]+$/; if(ingredientsEl.value.match(alphaExp)){ return true; }else{ alert(helperMsg2); ingredientsEl.focus(); return false;} return true; } </script> I am trying to write a javascript to open multiple websites in the same window for Internet Explorer. However I keep getting the website opening in a new window. Here is my code. Code: var url = [ "http://www.google.com", "http://www.yahoo.com", "http://www.msn.com" ]; var interval = 3000; var startTime = 0; for (i = 0; i < url.length; i++) { startTime = startTime + interval; setTimeout("openWindow("+i+")", startTime); } function openWindow(num) { window.open(url[num],'mywindow','width=800,height=600,menubar=yes,status=yes,location=yes,toolbar=yes,scrollbars=yes'); } So currently, this code behaves like this. Every 3 seconds, it opens up a new website. However this code I wrote opens google.com in a new window, then yahoo.com in a new window and so on. I want it to open all the websites in the same window. How do I achieve this? Hi, Can someone direct me to what do i need to get something like this going: When a user clicks on a button to focus a windows program thats already running Thanks I maintain a website for a small local restaurant. I do this with FrontPage so I know very little coding. I have an upload manager so the owner can remotely upload a txt or doc file of daily specials to a folder on the server. I would like to put a java script into one of the web pages that would open and display this file on page load. Is that possible and can someone help with the code, Thanks How to add an .mp3 file using java-script with HTML. I wish to add an mp3 file as a background music to my webpage. It should load automatically while user viewing my home page. I'm doing a project in php. "Give me a simple and easiest guideline for me" -thank you |