daily pastebin goal
10%
SHARE
TWEET

Untitled

a guest May 26th, 2018 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var nav     =    document.getElementById('nav'),
  2.     links   =    nav.getElementsByTagName('a'),
  3.     select  =    document.createElement('select'),
  4.     option  =    document.createElement('option');
  5.    
  6. for (var i = 0; i < links.length; i++){
  7.     var link    =    links[i],
  8.         _option =    option.cloneNode(false);
  9.     _option.value = link.href; // Set the option's value to the original link
  10.     _option.innerHTML = link.innerHTML; // Set the option's text to the original text
  11.     // if this link matches the current URL, add a selected attribute
  12.     if( window.location.href == link.href ) {
  13.         _option.selected = 'selected';
  14.     }
  15.     select.appendChild(_option);
  16. };
  17.  
  18. select.addEventListener('change', function() {
  19.     window.location = select.value;
  20. }, false);
  21.  
  22. nav.parentNode.insertBefore(select, nav);
  23. nav.style.display = 'none';
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top