Welcome to TalkGraphics.com
Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  1. #1

    Question Button To Close The Current Window/Page

    Hi,
    I'm trying to add a bit of code behind a button to close the current window. I've had partial success but not quite sussed it.

    The two styles of 'close' code I've seen are:

    Close Window Button:

    <form>
    <input type="button" value="Close Window" onClick="self.close()">
    </form>

    Close Window Text Link:

    <a href="Javascript:self.close();">Close Window</a>

    I've used the button style with success in the placeholder field for my bespoke button. It works but a standard style form button appears instead of my bespoke button.

    This is probably a real 'school boy error' but it's getting a bit frustrating.

    Can anyone tell me the correct way to achieve this please?

    Thanks in advance & Best Regards.


    TD

  2. #2

    Default Re: Button To Close The Current Window/Page

    Change the form input type attribute to use an image instead:

    example:

    <input type="image" name="myclicker" src="index_htm_files/image.jpg" width="55" height="22">

    image.jpg must exist in the index_htm_files folder of course.

  3. #3

    Lightbulb Re: Button To Close The Current Window/Page

    Hi Steve,
    thanks for the prompt reply. I think I get the idea but just one further question, before I give it a go - if I may.

    On export WD6 renames images by default to numbers (e.g. 12345.jpg), so will 12345.jpg be sufficient for the image name or does it need to be a proper name (e.g. close_button.jpg).

    I'm just wondering whether on re-export WD will change the numbering on the graphics as part of it's 'tidy-up' and thus the code snippet might reference a totally different .jpg by accident.

    Best regards


    TD

  4. #4
    Join Date
    Aug 2000
    Location
    Placitas, New Mexico, USA
    Posts
    41,524

    Default Re: Button To Close The Current Window/Page

    Select your image, and open the Names dialog (Utilities > Names).

    Use this format filename=yourfilename As Steve likes to admonish me, do not use the extension, if you need to specify PNG or JPG do this in the Image tab of the Web Properties.

    The image will be exported with the file name and will be exported as such whenever you export your site.

  5. #5

    Default Re: Button To Close The Current Window/Page

    Excellent. Thank you both very much for your help. Much appreciated!

    Best Regards

    TD

  6. #6

    Default Re: Button To Close The Current Window/Page

    Quote Originally Posted by Technoir Design View Post
    Close Window Text Link:
    <a href="Javascript:self.close();">Close Window</a>
    You mean you are putting this into the address box? Just put this instead:
    javascript:document.close();

  7. #7
    Join Date
    Dec 2000
    Location
    Hautes Pyrénées, France
    Posts
    5,083

    Default Re: Button To Close The Current Window/Page

    Check out this tutorial which may help you:

    http://www.javascript-coder.com/wind...ow-close.phtml


  8. #8
    Join Date
    Aug 2000
    Location
    Placitas, New Mexico, USA
    Posts
    41,524

    Default Re: Button To Close The Current Window/Page

    TD and anyone else

    John Horn advises putting the image name in quotes

    filename="imagename"

    This works fine and the exported file now has a correct name.

  9. #9

    Info Re: Button To Close The Current Window/Page

    Hi All,
    well, I've spent the last 24 hrs looking at this and for some reason, I still can't quite get it to work.

    I've tried using Sledgers form based solution (via the placeholder field) but the graphic was messing up my button rollover and I haven't solved that, yet.

    Using javascript:self.close() in the URL/address line was where I started from and after @Add.O.B.'s suggestion I went back to that.

    I'm no javascript expert (actually, barely a novice) but I have since learned that browsers will ask you to confirm the window closure, unless that window was also opened via a javascript:window.open().

    The need to confirm was really bugging me and then I came across this solution on a forum - window.open('','_self');window.close(). So, I tried it, using the URL/Address line properties of my button graphic.

    Results are in. Works perfectly in IE8 & Google Chrome! Sadly, doesn't seem to be working in Firefox... I tend to use Firefox and normally find it behaves better than the others - but not quite in this case. Pity. Maybe a bit more investigation will do the trick.

    Anyway, I thought I'd share this with you guys. Maybe you already knew this but it took me a good while to find it. So, if it saves someone else a few hours searching, I'll be satisfied.

    If anyone has any thoughts re: why Firefox isn't happy with this, I'd be very happy to hear from them.

    Thanks to all for your input so far on this.

    Best Regards


    TD
    Last edited by Technoir Design; 09 August 2010 at 01:31 PM.

  10. #10

    Default Re: Button To Close The Current Window/Page

    But have you tried javascript:document.close(); ?

 

 

Bookmarks

Posting Permissions

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