Coda Clips

jQuery open pdf in external window

// open pdf files in new window
$("a[@href$=pdf]").each(function() {
  $(this).attr('target', '_blank');
});

Added to by Davy Van Den Bremt

Install Clip


jQuery open links in external window

// open links in external window
$("a[@href^=http]").each(function() {
  if(this.href.indexOf(location.hostname) == -1) {
    $(this).click(function(){window.open(this.href);return false;});
  }
});

Added to by Davy Van Den Bremt

Install Clip


Add jquery in header

<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">google.load("jquery", "1");</script>

Added to by Vayu Robins

Install Clip


iPhone/iPod Force Redirect

<script language="javascript">
if (navigator.userAgent.indexOf('iPhone') != -1 ||
	navigator.userAgent.indexOf('iPod') != -1) {
window.location = "http://XXXX"
}
</script>

Added to by Paul George

Install Clip


Ajax - XMLHtmlRequest with "TOGGLE" effect

<script type="text/javascript">
function script()
{
var e = document.getElementById();
	if(e.innerHTML == "")	
{
var oRequest;
try {
       oRequest=new XMLHttpRequest();
    } catch (e)   {
    try {
         oRequest=new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
         try {
             oRequest=new ActiveXObject("Microsoft.XMLHTTP");
              } catch (e) {
                  alert("AJAX IS NOT SUPPORTED");
                 return false;
              }
        }
     }
  oRequest.onreadystatechange=function() {
   if(oRequest.readyState==4)
     {
         document.getElementById().innerHTML = oRequest.responseText;
     }
   }
 oRequest.open("GET","",true);
 oRequest.send(null);
 }
 else
	{e.innerHTML = "";}
	}
</script>

Added to by Dawson

Install Clip


Ajax - XMLHtmlRequest

<script type="text/javascript">
function script()
{
var e = document.getElementById("");
var oRequest;
try {
       oRequest=new XMLHttpRequest();
    } catch (e)   {
    try {
         oRequest=new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
         try {
             oRequest=new ActiveXObject("Microsoft.XMLHTTP");
              } catch (e) {
                  alert("YOUR BROWSER DOESN'T SUPPORT AJAX!");
                 return false;
              }
        }
     }
  oRequest.onreadystatechange=function() {
   if(oRequest.readyState==4)
     {
         document.getElementById("").innerHTML = oRequest.responseText;
     }
   }
 oRequest.open("GET",,true);
 oRequest.send(null);
 }
</script>

Added to by Dawson

Install Clip


Unify Div Heights (using jQuery)

// Make the height of all the innerDivs the same height based on the tallest one.
  function unifyHeights() 
  {
    var maxHeight = 0;
    $('div#OuterContainer').children('div').each(function(){
      var height = $(this).outerHeight();
      //alert(height);
      if ( height > maxHeight ) { maxHeight = height; }
    });
    $('div.innerDivs').css('height', maxHeight);
  }

Added to by Michael D. Noga

Install Clip


Get Value of Select and Load external file to div (jQuery)

$(document).ready(function(){
   $('#contactFormSelect :selected').val();
       $("#contactFormSelect").change(function(){
           $('#formLoader').load($('#contactFormSelect').val());
       });
});

Added to by Mark Evans

Install Clip


Sponsored Links: