Not signed in (Sign In)

SkillShare - A place to discuss Web Standards and Web Design topics

Categories

Vanilla 1.1.5a is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorArun
    • CommentTimeFeb 10th 2006
     permalink
    Sombody please help me to solve my problem,
    my doubt is in PHP

    My code is like the following...
    ----------------------
    <input type="button" value=" Cancel " onClick="javascript:window.close();" class="BtnG">
    ----------------------
    I don't know why this is not woring in Mozilla. this is just a simple javascript. Is there any other way to write JavaScript in Mozilla??

    Can anybody give me any good link that can explain the JavaScript compatiblity in Mozilla / All browser.

    ###############
    in another section i use the event.() method it is also not identifying........ In the Mozillla FireFox JavaScript Console, it is saying that event not defined................. DO WE NEED TO DEFINE IT??? ......... i don't think so......
    ................................
    I don't know why this is happening....?
  1.  permalink
    onclick="window.close()"
    • CommentAuthorArun
    • CommentTimeFeb 10th 2006
     permalink
    i tryed before sending this ( onclick="window.close()" )
    but this is also not working
  2.  permalink
    hmmmm. and its only Mozilla? it might be because of the way Mozilla uses tabbed browsing, might not beable to use that command for mozilla because there is an embedded window and it does not know which one you are reffering to..
    • CommentAuthorArun
    • CommentTimeFeb 10th 2006
     permalink
    Somebody help me pleaaasssssssseeeeeeee!!!!!!!!
    Its all abt my project,, Pleaseeeeeee.......... sombody........ Help me.
    •  
      CommentAuthortrovster
    • CommentTimeFeb 10th 2006
     permalink
    PHP has nothing to do with browser problems as they only get HTML.

    After a quick google search it shows an issue with Firefox's preferences - "firefox, you need to turn on the "pref("dom.allow_scripts_to_close_windows", false);" option"

    Also, inline JavaScript such as onClick should definitely be avoided, and camelCase events (if you're using XHTML, all attributes should be lowercase). You should be using external JavaScript.

    I recommend that you use a cross-browser add event script. Give the button an ID (if you want to use a class, you can, but you'll need a function called "getElementsByClassName", I recommend Robert Nymans and loop through each element).

    Try this (untested):

    function closeOnClick() {
    var link = document.getElementById('thisid');
    if(!link) return false // no match then stop here
    addEvent(link,'click',closeElement);
    }
    function closeElement() {
    window.close();
    }
    addEvent(window,'load',closeOnClick);
    •  
      CommentAuthornifkin
    • CommentTimeFeb 10th 2006 edited
     permalink
    A quick example of the same kind of thing that Trovster was talking about using jQuery as well:


    // when the DOM is ready to manipulate, do stuff to it.
    $(document).ready( function(){
    // add the onclick event to the object with id BtnG
    $("#BtnG").click( function(){ window.close(); });
    });
Add your comments
    Username Password
  • Format comments as (Help)