…. was ist das beste an javascript?

dass es IMMER OpenSource ist 😀

(d.h. es gibt kein binäres Format … kein byte-compilier… garkeinen compiler… es ist wie php eine reiner interpretersprache)

vorteil: Jeder lernt von Jedem!

those snippets saved my ass:

Get filename from URL using Javascript

credits: http://befused.com/javascript/get-filename-url

var url = window.location.pathname;
var filename = url.substring(url.lastIndexOf('/')+1);
alert(filename);

Dynamically loading an external JavaScript or CSS file

credits: http://www.javascriptkit.com/javatutors/loadjavascriptcss.shtml
<script type="text/javascript" src="dynamically_load_js_and_css_v2.js"></script>

the dynamically_load_js_and_css_v2.js file contains this:

/** ***** dynamically_load_js_and_css ******* */
// so if you need to globally include stuff, here you can do it without search replace/copy pasting all over the world
function dynamically_load_js_and_css(filename) {
    var filetype = filename.substring(filename.length, filename.length - 3);
    filetype = filetype.replace(".", "");

    if (filetype == "js") { // if filename is a external JavaScript file
        document.write('<script src="'+filename+'" type="text/javascript"></script>');
    } else if (filetype == "css") { // if filename is an external CSS file
        document.write('<link rel="stylesheet" type="text/css" href="'+filename+'"/>');
    }
}

dynamically_load_js_and_css("../js/jquery-1.10.2.js");

dynamically_load_js_and_css("file_that_uses_jquery_to_test_if_its_working.js");


dynamically_load_js_and_css("../js/jquery-1.10.2.js");
dynamically_load_js_and_css("../js/somescript.js");
dynamically_load_js_and_css("../js/some.css");

search and replace string

function replaceScript() {
    var toReplace = 'http://google.com';
    var replaceWith ='http://yahoo.com';
    document.body.innerHTML = document.body.innerHTML.replace(toReplace, replaceWith);
}

credits: http://stackoverflow.com/questions/5951801/find-and-replace-string

-> i love this site! 😉 but the “you need 10 more points to make shit” … really wrecks my nerves.

liked this article?

  • only together we can create a truly free world
  • plz support dwaves to keep it up & running!
  • (yes the info on the internet is (mostly) free but beer is still not free (still have to work on that))
  • really really hate advertisement
  • contribute: whenever a solution was found, blog about it for others to find!
  • talk about, recommend & link to this blog and articles
  • thanks to all who contribute!
admin