Jump to content

Matej

Members
  • Posts

    185
  • Joined

  • Last visited

Everything posted by Matej

  1. basicly whenever i invoke function with setTimeout within that function that i want to invoke , the setTimeOut works as setTimeout+setInterval ?
  2. well , think i still dont get why it is invoking itself in intervals (setInterval is NOT there and setTimeout is just delaying invoke of function) i would understand it , if there was setInterval... but setTimeout which just delay invoke of the function..
  3. http://jsfiddle.net/N2aP2/ i tried it here , so it seems it really works like (for)loop , but why is setTimeout behaving like setInterval?
  4. so when there is increment in if statement it behaves like (for)loop?
  5. yo, this code var i = 0;function swapImage() { var kk=document.getElementById("branka");kk.src=path[i];var mm=document.getElementById("vole");mm.setAttribute("href",change[i]); if(i < path.length - 1&& i<change.length-1){ i++;} else {i = 0;} setTimeout("swapImage()",3000); } window.onload=swapImage; is used for bad looking slide-show , but my question is , why is this function executed every 3s? it should be executed once (it check if i<array.length and if its true i goes up(i++))no? there isnt setInterval , so why is this function executed every 3s? there is only delay wth seTimeout , thanks for answer
  6. Matej

    ajax

    im opening(double clicking) on .html file
  7. Matej

    ajax

    Hi , im trying to understand ajax , here is my script <!DOCTYPE html><html><head><script>function loadXMLDoc(){var xmlhttp;if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); }else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("myDiv").innerHTML=xmlhttp.responseText; } }xmlhttp.open("get","texttest.txt",true);xmlhttp.send();}</script></head><body> <div id="myDiv"><h2>Let AJAX change this text</h2></div><button type="button" onclick="loadXMLDoc()">Change Content</button> </body></html> the texttest.txt contains just <p>hello world</p> but it isnt working , it writes Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'file can anyone help me please?
  8. Matej

    window.parent

    well .... im stupid , i just realized it ...
  9. Matej

    window.parent

    Hi , why do i have to set "document.body" here: function myFunction() {parent.document.body.style.backgroundColor = "red";} ? window.parent reffers to a parent window so why do i have to "set again" the parent window by "document.body"? example http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_win_parent2 thanks for answers
  10. Hi i have script <p id="lol" onmouseover="zmena()" onmouseout="sopka()">ahoj</p> var x=document.getElementById("lol");var start;var zacni=0;function zmena(){if(x.innerHTML=="ahoj"){x.innerHTML="cau"}else if(x.innerHTML=="cau"){x.innerHTML="hi"}else if(x.innerHTML=="hi"){x.innerHTML="ahoj"} zacni=1;} function sopka(){x.innerHTML="ahoj";zacni=0} function timing(){if(zacni){start=setInterval(function(){zacni()},1000);}else{clearInterval(start);}} window.onload=timing; I wanna start again chaning of changing innerHTML on mouseover , but it doesnt work can someone help?
  11. Matej

    boolean change

    Thanks! got it with global variable , but im curious , how would it looks like as closure?
  12. Hi , i have simple boolean in this www.jsfiddle.net/f4XA6/ but it does not work (change property) , can anyone help?
  13. Matej

    z-index

    Hi , i have http://jsfiddle.net/5ayy4/ but i want the text to be visible only in the red box , i tried it with z-index but its not working . Any adice? thanks for answering
  14. Hello gentlemen , what's the difference between .childNodes and .children?
  15. Matej

    var

    thanks , so basicly it does not change anything till i "invoke it" or set the value of it to something , also where can i found the documentation about stuffs like this? like what returns value etc.
  16. Matej

    var

    well that means that i have to put toUpperCase() into variable right? but its not working either
  17. Matej

    var

    Hi , why do i have to set x.value=x.value.toUpperCase() here http://www.w3schools.com/js/tryit.asp?filename=tryjs_onchange? and why does not it work with just x.value.toUpperCase()?Thanks for answering quite stupid question
  18. thanks , is there any difference between function(e){alert(e.target);} and function(){alert(event.target);} there is written the second case in documentation , but it does not work , but the first does.
  19. Hello gentlemen. Im trying to understand addEventListener and i came to this script <p id="lol" > hello world </p> var g=document.getElementById("lol");g.addEventListener("click",myfunction(){alert(event.target);},false); but it does not work , i tried it with "true"(altought im not quite suire if i understand when to use false /true).
  20. Matej

    firstchild

    thanks! and what would be lastChild of <tr id="t1"><td>one</td></tr>? it shows "TD" but isnt it #text with nodeValue "one"?
  21. Matej

    firstchild

    Thanks so basicly , every break counts as node here right?
  22. Matej

    firstchild

    it does the same thing when i add spacing and breaks also it shows #text via nodeName (on both of the cases)
  23. Matej

    firstchild

    Hello gentlemen <table id="outside"> <tr><td id="t1">one</td></tr> <tr><td id="t2">two</td></tr></table> var t2 = document.getElementById("t2");alert(t2.firstChild.nodeValue) Why does this alert "two" (value of t2) while t2 does not have childrens? but when i use var t2 = document.getElementById("outside");alert(t2.firstChild.nodeValue) it does not alert anything Also can someone explain to me when do i use "true" and when do i use "false" in element.addEventListener()? Thanks for answering and have a nice day
  24. Thanks , i made it working with this var video = document.querySelector("#videoElement");navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia || navigator.oGetUserMedia;if (navigator.getUserMedia) {navigator.getUserMedia({video: true}, handleVideo, videoError);}function handleVideo(stream) {video.src = window.URL.createObjectURL(stream);}function videoError(e) {// do something} i put it in function and made it onclick event , but i was wondering , how could i make that function stop?
  25. Hello gentlemen i'd like to "connect" webcam and my website with webcam(something like chatroullete but instead , you will see your own image from webcam , you and only you") but i have no idea how to do it . Would you be so kind and give me some hint or idea how to do it? Thanks , and have a nice day.
×
×
  • Create New...