Google Sites JavaScript (Inline JavaScript)

Google Sites JavaScript (Inline JavaScript)


Inline JavaScript is only available in between  Form Elements directly in Google Sites. 

The Form elements will automatically be rendered as a Google Gadget.

JavaScript 'Alert' Box

The Alert Box can be used to notify or display information. the alert box Pops up to Display the message you want.

Anchor & 'Alert' Box

<form xmlns="http://www.w3.org/1999/xhtml">
<a href="#" id="HelloWorld" onClick="alert('Hello Google Sites World')">onClick</a>
</form>

Inline Javascript : Alert Box


Button 'Alert' Box
<form xmlns="http://www.w3.org/1999/xhtml">
<input id="HelloWorld" onClick="alert('Hello Google Sites World')" type="button"  value="HelloWorld"/>
</form>




Selection Box 'Alert' Box
<form xmlns="http://www.w3.org/1999/xhtml">
<select height="50px" 

onChange="alert(this.options[this.selectedIndex].value)">
    <option value="">Choose a Link</option>
    <option value="http://maps.google.com/">Google Maps</option>
    <option value="http://www.google.com/">Google Search</option>
    <option value="http://images.google.com/">Google Image Search</option>
    <option value="http://calendar.google.com/">Google Calendar</option>
    <option value="http://translate.google.com/">Google Translate</option>
    </select>
</form>


Confirmation Box

The confirmation Dialog Box Pops up from a webpage to display 2 options "OK" to continue or "Cancel".


<a href="http://www.goopal.org/" onclick="return (confirm('Follow this link?'))">Goopal - Google Sites Examples</a>

Popup Window

Full Inline JavaScript 'Popup Window' Function

You can drag the following bookmarklets into your browser Firefox/Chrome , so you can run the javascript code from your browser on any webpage.

<Object>
<a class="marker" href="javascript:(function(){var a=window,b=document,c=encodeURIComponent,d=a.open('http://www.google.com/cse/manage/bookmarklet?url='+c(b.location) + '\x26hl=en','coop_popup','left='+((a.screenX||a.screenLeft)+10)+',top='+((a.screenY||a.screenTop)+10)+',height=420px,width=700px,resizable=1,alwaysRaised=1,scrollbars=1');a.setTimeout(function(){d.focus()},300)})();" title="Drag this 'Google Marker' Link into the Browsers Address Bar"> Google Marker</a>
<Object>




JavaScript 

It is possible to attach a jQuery .Click() Javascript Event using the HTML Box . This improves loading times and methods / events / listeneners latency within a webpage.