Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Regular Coder
    Join Date
    Dec 2003
    Location
    America
    Posts
    544
    Thanks
    0
    Thanked 0 Times in 0 Posts

    My function is not working, and i dont know why.

    Ok, i have a function that for whatever reasons, does not seem to work, and i would like to know why:

    Code:
    function addWindow()
    {
    var fox;
    var fileAddy = "Adding.html";
    windowName = "Math_Window_add";
    
    var features;
    
    features = "width=440px,height=150px,"
    features+="top=300px,left=300px"
    
    fox=window.open(fileAddy,windName,features);
    
    fox.focus();
    }
    Can anyone help me? when i click on the button that is supposed to launch my window, i get a window, but it says, about: blank, and it has more features than what are listed above. All i want are the width, height, top, and left, properties, but no other features.
    LovesWar

  • #2
    Regular Coder
    Join Date
    Jun 2004
    Location
    underground
    Posts
    186
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Getting about:blank means that there was a problem with the url parameter - either the file not being found, or not specified.

    Many parameters have a default value of on, so must be explicitely turned off.

    You have a spelling error: windowName < > windName

  • #3
    Regular Coder
    Join Date
    Nov 2002
    Location
    Manchester, UK
    Posts
    533
    Thanks
    4
    Thanked 1 Time in 1 Post
    try changing this line

    fox=window.open(fileAddy,windName,features);

    to this

    fox=window.open(fileAddy,windowName,features);

    note the windowName - you missed out the "ow" in the first line.... that should work now?

  • #4
    Regular Coder
    Join Date
    Dec 2003
    Location
    America
    Posts
    544
    Thanks
    0
    Thanked 0 Times in 0 Posts

    I have done that as well, but it isnt working

    I have done that, but somehow, it isnt working at all. Here again:

    Code:
    //  This launches the adding window:
    
    function addWindow()
    {
    var fox;
    var fileAddy="\"Math_Addition.html\"";
    windName="\"Math_Window_add\"";
    
    var features;
    
    features="\"width=440px,height=150px,";
    features+="top=300px,left=300px\"";
    
    fox=window.open(fileAddy,windName,features);
    
    fox.focus();
    }
    As you can see, i have even taken off the typo in the variable windName, and still, i get a regular window with all the features that i do not want, and it just says about blank in the URL field, which doesnt make sense since it's all in the same folder, and not outside the folder.

    Somehow, it just doesnt work, and this has always been the friggin problem with my aims to learn javascript. Half the time, the scripts do not work, and its always some cheesy work around that i have to do that has nothing to do with the general syntax structure. Like the background property, i had to do something like document.body.background= instead of something like document.bgcolor=. Its the same object, but with a different property, but yet the syntax had to be different for both property, even though both properties were of the same object. Here's a body tag:

    Code:
    <body bgcolor="red" background="imagWhatever.jpg">
    .

    Its the same object, but the accessing of each property required a different syntax which is absurd. Compare:

    Code:
    var bgColorProp= document.bgcolor= obj.options[the_Chosen].value
    
    var bgImagProp=document.body.background=obj.options[the_Chosen].value
    Its the same object, but yet, each property of the same object requires a different syntax? This is just plain absurd. There's no logic here.

    At any rate, the function does not work.
    LovesWar

  • #5
    Regular Coder
    Join Date
    Dec 2003
    Location
    America
    Posts
    544
    Thanks
    0
    Thanked 0 Times in 0 Posts

    I found the error

    I found the error. I forgot the change one of the functions name, so basically there was 2 different functions with the same name, and somehow, it chose the one that didnt have the code in. Go figure. LOL. I love looking like the end of a mules end. LOL
    LovesWar

  • #6
    Regular Coder
    Join Date
    Nov 2002
    Location
    Manchester, UK
    Posts
    533
    Thanks
    4
    Thanked 1 Time in 1 Post
    hehe, glad you got it sorted!! Javascript is a mare sometimes and baffles everyone...sometimes the simplist solution is staring you right in the face.... do you have a JS debugger? I got the one from Microsoft for IE which is really good - it actually tells you the line where the error is - rather than saying a line which clearly doesnt have the error....

    I think Mozilla have a decent JS debugger in as well.....

  • #7
    Regular Coder
    Join Date
    Dec 2003
    Location
    America
    Posts
    544
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Internet Explorer blows

    I really do not like Explorer. I've tried adjusting the width, and height properties of the pop up so that it would be ideal, and it just seems like no matter how many times i just the properties, one of them stays the same size no matter. I even reversed the order of the properties, and sure enough, one side remains the same. I may not be the smart coder in the world, but i know logic, and i got to say, that IE lacks it half the friggin time.
    LovesWar

  • #8
    Regular Coder
    Join Date
    Jun 2004
    Location
    underground
    Posts
    186
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by SpiritualStorms
    Somehow, it just doesnt work, and this has always been the friggin problem with my aims to learn javascript. Half the time, the scripts do not work, and its always some cheesy work around that i have to do that has nothing to do with the general syntax structure. Like the background property, i had to do something like document.body.background= instead of something like document.bgcolor=. Its the same object, but with a different property, but yet the syntax had to be different for both property, even though both properties were of the same object. Here's a body tag:

    Code:
    <body bgcolor="red" background="imagWhatever.jpg">
    .

    Its the same object, but the accessing of each property required a different syntax which is absurd. Compare:

    Code:
    var bgColorProp= document.bgcolor= obj.options[the_Chosen].value
    
    var bgImagProp=document.body.background=obj.options[the_Chosen].value
    Its the same object, but yet, each property of the same object requires a different syntax? This is just plain absurd. There's no logic here.
    Javascript, and JScript are seperate from the object libraries that browsers implement.

    Properties of HTML, DOM, DHTML, CSS, etc. are seperate from each other and js.

    There is often more than one way to accomplish the same thing accross different object models, and some properties and methods of those have been deprecated, as new ones have been added.

    Though it all may seem similar, keeping such distinctions in mind may be helpful.

  • #9
    Regular Coder
    Join Date
    Dec 2003
    Location
    America
    Posts
    544
    Thanks
    0
    Thanked 0 Times in 0 Posts

    hence why this seems like a joke

    I have been told theres more than one DOM modal, but i was also under the impression that the W3C was trying to standardise the discord. This language gives me more a head-ache then anything else. Too many modals for the same goal. Too absurd really. I may just give up JavaScript altogether, and just stick to Perl, Java, or PHP.
    LovesWar

  • #10
    Regular Coder
    Join Date
    Jun 2004
    Location
    underground
    Posts
    186
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'd not equate flexibility and progress with absurdity, but that's subjective.

  • #11
    Senior Coder
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    1,063
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Personnaly, I think javascript is incredible.

    anyways, my try at your bg color problem:

    document.body.background= THIS MAKES SENCE. you get the document elemtent. In it, you find the body element. you set it's background attribute to whatever.
    document.bgcolor= THIS IS WEIRD. I did not know that the document had a bgcolor attribute..
    document.body.bgcolor= SHOULD WORK..

    I don't really know, but my solution to this is, well, this:
    where is the attribute I want? on the body.
    document.body
    document.getElementById("theBody")
    document.chilNodes[0]
    whatever, they all work.
    which attribute do I wanna set? the bgcolor
    .bgcolor
    .setAttribute("bgcolor","value")
    nope, it's background..
    .background
    .setAttribute("background","value")
    nope, it's style..
    .style.backgroundColor
    .style.background

    so this works I think:
    document.[body-getElementById("theBody")-childNodes[0]].[bgcolor-setAttribute("bgcolor","value")-style.backgroundColor-style.background]
    [you can choose this-or this]both work.

    for this I would suggest
    document.body.style.background=
    because it's the most intuitive...
    you want to set the background to red. this background is part of the style of the body, which is contained in the document...

    Anyways, I'm no pro, but I find it fairly simple to find a solution that works since there are so much possibilities...
    Javascript is great! lol
    Shawn

  • #12
    Regular Coder
    Join Date
    Dec 2003
    Location
    America
    Posts
    544
    Thanks
    0
    Thanked 0 Times in 0 Posts

    I think you missed my point

    I know the theory for the dot syntax. Thats not really my issue. My issue is with the fact that the syntax is inconsistant.

    document.body.background= THIS MAKES SENCE. you get the document elemtent. In it, you find the body element. you set it's background attribute to whatever.
    document.bgcolor= THIS IS WEIRD. I did not know that the document had a bgcolor attribute..
    document.body.bgcolor= SHOULD WORK..
    See what i mean?

    As for your last comment, actually, document refers to the very file that you will be placing your code in, so yes, it makes sense to think that its document.bgcolor, since document refers to the webpage.

    But the point is, that is really irritating as hell trying to learn something that seems arbitrary for a lot of cases. Secondly, body, is a microsoft property, and not necessarily a Netscape property.

    for this I would suggest
    document.body.style.background=
    because it's the most intuitive...
    Intuitive, you say? Seems like intuition is a rather subjective thing. The style part, well, thats true if you assume that you have styles on your document, and not just straight HTML. Hence the subjectivity of it all.

    My over-all point is, that this huge war between NetScape, and Microsoft is more an issue of politics than anything else. Microsoft is just the Johnny come lately, and they want to basically re-invent the whole friggin wheel, hence, why they have properties, and methods, that NetScape does not have.

    My understanding is, that if you have a style definition of any of your tags, that you would have to list that property in order to access the actual property of the style definition that is a part of a tag. Otherwise, it does not seem intuitive to me to think i would have to include a style property for a path for a document that does not have any style definitions of any sort for any of the tags. If it's just straight HTML, and no CSS, then really, whats the point to saying something like, document.body.style.background=? This would only make sense, if i had something like,

    Code:
    <body class="SomeName">
    
    or
    
    <body style="bla bla bla bla bla">
    If any of the above cases were true, then yes, i could see the logic in having the style property listed in the dot syntax. Otherwise, it does not make sense at all.
    Last edited by SpiritualStorms; 06-27-2004 at 06:25 AM.
    LovesWar

  • #13
    Regular Coder
    Join Date
    Dec 2003
    Location
    America
    Posts
    544
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Sort of, but not totally correct........

    There are distinctions, certainly, but only contextually speaking:

    From Neofibril:

    Javascript, and JScript are seperate from the object libraries that browsers implement.

    Properties of HTML, DOM, DHTML, CSS, etc. are seperate from each other and js.

    There is often more than one way to accomplish the same thing accross different object models, and some properties and methods of those have been deprecated, as new ones have been added.

    Though it all may seem similar, keeping such distinctions in mind may be helpful.
    Actually, the only real difference is in the politics between NetScape, and MicroSoft. HTML is a mark up language, and CSS is simply a higher version, or in some ways, an Extension to HTML. DOM only refers to the organisational structure of the objects that could exist on a document, nothing more. DHTML is only a hybrid of JavaScript, and HTML. And this only means the incorporation of JavaScript with HTML, which is just another way of saying, JavaScript, and HTML. In this sense, there's no real distinction per se, or as n PHP versus PERL, or Java versus C++. To me the distinctions only arise in how you do certain things, but its not a real distincion as in a triangle, and a circle.

    At any rate, the protocals used by NetSCape, and MicroSoft is about the only thing that aggrevate the hell out of me. Just when you think you have understood the language, there's these curve-balls thrown your way, and it makes you feel like you dont understand a single thing. Mircosoft use the array all, while NetScape use layers. So here, its like, hell, why think you have figured out something, when what works for one browser does not work for another, even though, technically speaking, both browsers are dealing with the issues of HTML, and JavaScript.
    Last edited by SpiritualStorms; 06-27-2004 at 09:23 AM.
    LovesWar

  • #14
    Regular Coder
    Join Date
    Jun 2004
    Location
    underground
    Posts
    186
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by SpiritualStorms
    There are distinctions, certainly, but only contextually speaking:
    Actually, the only real difference is in the politics between NetScape, and MicroSoft. HTML is a mark up language, and CSS is simply a higher version, or in some ways, an Extension to HTML. DOM only refers to the organisational structure of the objects that could exist on a document, nothing more. DHTML is only a hybrid of JavaScript, and HTML. And this only means the incorporation of JavaScript with HTML, which is just another way of saying, JavaScript, and HTML. In this sense, there's no real distinction per se, or as n PHP versus PERL, or Java versus C++. To me the distinctions only arise in how you do certain things, but its not a real distincion as in a triangle, and a circle.

    At any rate, the protocals used by NetSCape, and MicroSoft is about the only thing that aggrevate the hell out of me. Just when you think you have understood the language, there's these curve-balls thrown your way, and it makes you feel like you dont understand a single thing. Mircosoft use the array all, while NetScape use layers. So here, its like, hell, why think you have figured out something, when what works for one browser does not work for another, even though, technically speaking, both browsers are dealing with the issues of HTML, and JavaScript.
    DOM is a W3C object model.
    DHTML is an Internet Explorer object model.
    HTML, CSS, DHTML, DOM, are all bundled in the Microsoft HTML Object Library. Their properties are accessed differently. That was my point.
    I'm guessing you'll twist that into another aimless argument...

  • #15
    Regular Coder
    Join Date
    Dec 2003
    Location
    America
    Posts
    544
    Thanks
    0
    Thanked 0 Times in 0 Posts

    hhmmmm

    Interesting remarks:

    Neo:

    I'd not equate flexibility and progress with absurdity, but that's subjective.
    Flexibility? The opposite of rigidity? But what is rigidity exactly? Strictness perhaps? An absense of narrowness? Or an absense of precision?

    I hardly think restrictions equals flexibility. When i have to stick to a particular, and specific protocal, i hardly think that to be flexible.

    Progress? Now that's that an interesting term too. Theoretically, progress means advancement, and advancement means a reduction of the inconvenient. This too is not proved to be the case with this programming language. I do not feel my life improved by the strictures of a tight, and often, irrational, demand of correct syntax grammer.

    All in all, true flexibility would involve, freedom, and adoptability, not from the programmers perspective, but from the language itself.
    Last edited by SpiritualStorms; 06-27-2004 at 03:20 PM.
    LovesWar


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •