spirit posteets tagged javascript  [ Profile ]

Sort by: Date / Title /

  1. 3 months ago
    1. anchor = window.location.hash;
    2. anchor = anchor.substring(1,anchor.length); // enleve le #
    3.  
    4. //-- Juste pour l'archivage, voici le code que j'utilisais avant de savoir qu'une fonction js existait
    5. var url = document.location.toString();
    6. if (myFile.match('#')) {
    7.     var anchor = myFile.split('#')[1];
    8. }
  2. 3 months ago
    1. // Le JS dans la div ci-dessous a été inséré par une requete AJAX
    2. // <div id='mydiv'> <script type='text/javascript'> [...] </script> </div>
    3.  
    4. var div = document.getElementById('mydiv');
    5. div.innerHTML = innerHTML;
    6. var x = div.getElementsByTagName("script");
    7. for(var i=0;i<x.length;i++)
    8. {
    9.        eval(x[i].text);
    10. }
  3. 9 months ago
    1. Remove the events from the options, use an event directly on the select instead.
    2.  
    3. function myfunc(value) {
    4.   alert(value);
    5. }
    6. ...
    7. <select onchange="myfunc(this.options[this.selectedIndex].value)">
    8.   <option value="1">Item1</option>
    9.   <option  value="2">Item2</option>
    10. </select>
  4. sponsorised links
  5. 10 months ago
    1. var myfunc = function(optional) {
    2.   if (typeof optional == "undefined") {
    3.     optional = "default value";
    4.   }
    5.   alert(optional);
    6. }
  6. 1 year ago
    1. $.create = function() {
    2.   var ret = [], a = arguments, i, e;
    3.   a = a[0].constructor == Array ? a[0] : a;
    4.   for(i=0; i<a.length; i++) {
    5.     if(a[i+1] && a[i+1].constructor == Object) { // item is element if attributes follow
    6.       e = document.createElement(a[i]);
    7.       $(e).attr(a[++i]); // apply attributes
    8.       if (a[i] == 'table') alert ('titi');
    9.       if(a[i+1] && a[i+1].constructor == Array) $(e).append($.create(a[++i])); // optional children
    10.       ret.push(e);
    11.     } else { // item is just a text node
    12.       ret.push(document.createTextNode(a[i]));
    13.     }
    14.   }
    15.  
    16.   return ret;
    17. };
    18.  
    19.  
    20. // Usage
    21. $.create(
    22.    'table', { 'class':"MyTable" }, [
    23.       'tbody', {}, [
    24.          'tr', { 'class':"MyTableRow" }, [
    25.             'td', { 'class':"MyTableCol1" }, [ "howdy" ],
    26.             'td', { 'class':"MyTableCol2" }, [
    27.                "Link:", 'a', { 'class':"MyLink", 'href':"http://www.example.com" }, ["example.com"] ] ],
    28.          'tr', { 'class':"MyTableRow2" }, [
    29.             'td', { 'class':"MyTableCol1" }, [ "howdy" ],
    30.             'td', { 'class':"MyTableCol2" }, [
    31.                "Link:", 'a', { 'class':"MyLink", 'href':"http://www.example.com" }, ["example.com"] ] ] ] ]);

First / Previous / Next / Last / Page 1 of 1 (5 posteets)