Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Please help me fix my JavaScript errors

Featured Replies

Hi

 

I'm trying to get my website to comply with w3.org's rules for HTML validation.

 

I have a script in my page that is for Google Translate Tool and it's giving me some problem.

 

The code for this tool is:

<div id="google_translate_element"></div><script>
function googleTranslateElementInit() {
 new google.translate.TranslateElement({
   pageLanguage: 'en'
 }, 'google_translate_element');
}
</script><script src="http://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

 

The errors that w3.org gives me are:

<div id="google_translate_element"></div><script>

 

 

The attribute given above is required for an element that you've used, but you have omitted it. For instance, in most HTML and XHTML document types the "type" attribute is required on the "script" element and the "alt" attribute is required for the "img" element.

 

Typical values for type are type="text/css" for <style> and type="text/javascript" for <script>.

 

And the other one:

 

late.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

 

 

The attribute given above is required for an element that you've used, but you have omitted it. For instance, in most HTML and XHTML document types the "type" attribute is required on the "script" element and the "alt" attribute is required for the "img" element.

 

Typical values for type are type="text/css" for <style> and type="text/javascript" for <script>.

 

 

The thing is I am not really familiar with JavaScript much. All I want is to use this translate tool and to comply with w3.org's rules.

Can someone please explain to me how I can fix the two errors that w3.org gives me?

 

Thanks. I would be really grateful.

Try:

 

<div id="google_translate_element"></div><script type="text/javascript">

 

and:

 

<script type="text/javascript" src="http://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

 

They aren't JavaScript errors. type="" is an attribute that the W3C requires for validation when using the <script> tag.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.