Question:
Need help in importing a specific JavaScript file to a web page.?
Vec
2009-06-24 16:37:42 UTC
I am no JavaScript genius.

I am using the Credo Rock the Vote widget, http://www.rockthevote.com/rtv_register.html .

However, when I am validating my pages from W3C, I always get 10 errors, all stemming from the widget code.

What I am looking for is to do a simple import from a saved .js file i .e. , where when clicked will open this widget. But my problem is how do I create the .js file so that it works the same as it does now? ( see code below)

Here is an example of the code in action: http://www.momsrising.org/momsvotebanners



---------------------------------------------------------

Register to Vote: Rock the Vote, powered by Credo Mobilesrc="images/rockthevote.gif" />



------------------------------------------------------------------
Three answers:
anonymous
2009-06-25 00:15:03 UTC
10 errors should be easy to correct. Much of the code given on web sites for copy/paste is outdated are coded in a "don't care about standards" way. See one of the answers here. If everyone would code to standards, then all browser developers could dump the backward compatibility codes and make browsers leaner and meaner.



Ron
palmettomissle
2009-06-24 17:03:15 UTC
your HTML would look like





Register to Vote: Rock the Vote with MomsRising.org



your .js file would look this

function Hi()

{if(typeof(WAReg)=='object')return false;if(!/WebKit\/[4-7]|MSIE [6-9]|Gecko\/200(51[12]|[6-9])|Opera\/9/.test(navigator.userAgent))return true;WAReg={launcherHtml:this.innerHTML,isStandalone:0};var d=document;var s=d.createElement('script');s.src='http://www.registrationbyworkingassets.com/client/wareg.js?popin=1&api_key=VoybZLkyfj4Zf0Aa8cQOMZDQUPs&lang=&%72eg_id=&r='+Math.random();d.body.appendChild(s);this.innerHTML='Please wait...';return false;}
chillininvt
2009-06-24 16:47:03 UTC
I wouldnt spend a whole lot of time worry about your pages validating to W3C specifications. If the code is working let it be. Just because something doesnt validate to W3C doesnt mean that the browser is not able to interpret it. It mearly means W3C doesnt think the code is valid doesnt nessarily mean that it is not valid. So I would spend more time worry about something other than W3C validation. As long as you dont have an nested tags and your code is clean most browsers are smart enough to display it.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...