Jump to content

Matej

Members
  • Posts

    185
  • Joined

  • Last visited

Posts posted by Matej

  1. Thank you .

     

    Yea sorry , im not good at naming thins or subject :/

     

    anyway , i tried to add a child div to one of them here http://jsfiddle.net/hc4erouc/3/ but whenever i set both

     

    this.element.style.width=parseInt(this.element.parentNode.style.width/2)+"px"this.element.style.height=parseInt(this.element.parentNode.style.height/2)+"px"

    it aint working , but when i add just this

     

    this.element.style.width=parseInt(this.element.parentNode.style.width/2)+"px" // this works strange , it add width of element but instead of 50% of parent's width it adds 100% of parent's widththis.element.style.height=20+"px"
  2. thanks for answers x[date][attribute] does not work but i made it like this

     

    var datum = new Date();var mesiac = datum.getMonth();var den = datum.getDay() - 2;var zisti=x[mesiac];document.getElementById("lol").innerHTML="Today is  " +zisti[den]+"'s"+" namesday";
  3. Hello, is there any way to invoke json attribute like array or with variable?

    For example:

    var x = [    {1:"matej"},    {1:"adam"},    {1:"clyde"},    {1:"jozko"},    {1:"matej"},    {1:"jude"},    {1:"john"},    {1:"marek"},    {1:"juraj"},    {1:"alex",2:"alojz",3:"idiot",4:"RESULT"},    {1:"matej"},    {1:"andrek"},    {1:"matej"},    {1:"brano"}    ];var date=new Date().getMonth(); // 10var attribute=new Date()-getDay()-2; //4alert(x[date].attribute); // basicly i want it to alert "RESULT" , but this isnt working , i want to invoke lile this bcs i want it to change automaticly every day  

    I hope i made this clear , this is basicly something like on school sites which writes who has birthday every day.

     

    Thanks for answers

  4. Hello , i have a questions

    if i got it right , if i use call or apply , the function or object which is this code executed in with inherit specific properties ,

    for example

    function a(args){    b.apply(this,arguments); // here we said , that function a should inherit stuffs from function B , it does inherit alert("lol") , but why doesnt it inherit x also?     alert(x);} function b(){   alert("lol");var x=9;} a(); [/code] and second questionargument passing can be done by value or refference , value is usually primitive varriable like string or numberand refference is usually object. If i set [code]var g=9function call(x){x+=9;}call(g)[/code]

    var g inside function equals 18 , but globaly variable g still equals 9 , so why when i set

    var person=new Object;function call(x){x.name="david"}call(person)

    here if i call person.name outside of the function it equals "david" bcs i created copy of "person" and both of them reffer to one object in header;

    so why when i do this

    http://jsfiddle.net/nj5a84hm/ person.name="lol" and not "kek"? object should be passed by refference.

    (if objects are passed by value , person.name should be undeffined)

     

    Could someone explain it to me? thanks for answers

  5. ah you edited your post , so basicly this is string

    var text = '{"employees":[' +'{"firstName":"John","lastName":"Doe" },' +'{"firstName":"Anna","lastName":"Smith" },' +'{"firstName":"Peter","lastName":"Jones" }]}';

    and mine was basicly JSON object right

  6. Hi , im getting into json and i came to problem

     

    var x={"menu": {  "id": "file",  "value": "File",  "popup": {    "menuitem": [      {"value": "New", "onclick": "CreateNewDoc()"},      {"value": "Open", "onclick": "OpenDoc()"},      {"value": "Close", "onclick": "CloseDoc()"}    ]  }}}

     

    this is some random json i found on their site , but here comes my question:

    i tried to get value of "id"

     

    var getit=JSON.parse(x);document.getElementById("one"),innerHTML=getit.menu.id 

    but it aint workin , any help please?:)

  7. In the first case you're telling it the name of the function it has to use when the event happens, in the second case you're actually running the function right on that line and assigning whatever value the function returns to the "onmousemove" property.

    Well if first time i tell it , to use ahoj onmousemove , and second time just invoking ahoj with click (if i got it right) , why is chaning of innerHTML working like it should but div aint movin?

  8. Thanks for answers ,

     

     

    Yes i could move the last div with javascript but if i did that , the other content would not move automaticly so I dont want to move it with javascript , bcs i would like to use this method for menu on website , so whenever i click on button , the "menu" appears from top so the content of the site moves down so the menu have space and doesnt cover anything.

     

    So is there any method how to do it? did i set wrong position on something or?:)Thanks for answers

  9. Thanks , tried that example but it didnt work :/ (even used it whit given HTML code in that example

    Uncaught TypeError: Failed to execute 'scroll' on 'Window': 2 arguments required, but only 1 present. (index):54onmousedown (index):54 is the error - first time i have seen something like that , even tho there should be only 1 argument... :/

  10. ah , so basicly i DIDNT create that simulated event , i had to create it first

     

    var event = document.createEvent("Mouseevents");    event.initEvent("click",true,true);

    or

     

    var event = new MouseEvent('click', {'view': window,'bubbles': true,'cancelable': true})

     

    Which one is better? or it just depends on me

  11. Hi , would anyone be so kind and explained the dispatchEvent() to me? i've been looking after it but i did not understand it from mozilla , IE developers and so on

     

    Thanks for asnwers :)

×
×
  • Create New...