homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

"javascript: void(0);" problem
javascript: void(0);

 6:29 pm on Jan 9, 2009 (gmt 0)

I have these codes in website:

<td align="center">
<a href="javascript: void(0);" id="browse">Browse</a> ¦
<a href="javascript: void(0);" id="clear">Clear</a> ¦
<a href="javascript: void(0);" id="upload">Upload</a> ¦
<a href="javascript: void(0);" onclick="javascript: opener.location.reload(true); window.close();">Close</a>

Bu when i've clicked the Browse it was giving error. Link doesn't work for me. But my friend tried it. He says it works. So what is the problem? What can i do for work for me?



 8:26 pm on Jan 9, 2009 (gmt 0)

Hi! Welcome to the forums.

The first 3 links should be right as they are. Not wise, but they are OK.

I guess the code you pasted above is in a popup window, cos else has no meaning. So, the 4th link has some issues.
1. remove the 'javascript:' from the onclick event, no need for it.
2. in the highest location of the DOM tree there's no opener. It's in the window "branch". So your event should look like:

onclick="window.opener.location.reload(); window.close();"

I missed the true from the reload(), as far as I know it's not needed.

Hope this helps


 8:45 pm on Jan 9, 2009 (gmt 0)

Thank you for your reply.

Yes this page is in a popup window. I've deleted 'javascript:' and used onclick="window.opener.location.reload(); window.close();" But i still have same problem. When i've clicked the "Browse" it gives this error:


This problem is only for my PC. I mean this code works another PC. So i need different code for my PC. How can i change this code? Thanks...

[edited by: eelixduppy at 3:39 am (utc) on Jan. 10, 2009]
[edit reason] removed image [/edit]


 6:25 am on Jan 10, 2009 (gmt 0)

Should not be PC dependent. Browser likely, but not PC.
Hm. If I understand you right, then You pop-up a window on page1.html, then when you close the popup you want to refresh the parent window, aka the opener. If so, mind if I suggest another way?
Take this function and paste it in your popup's head section, in a script element:

function Parent() {
window.opener.location.href = window.opener.location.href;
if (window.opener.progressWindow){

Then, the 4th link in your example should look like this:

<a href="#" onclick="Parent()">close</a>

This should close the pop-up window and refresh the opener parent. Not an A+ grade function, but works.


 7:02 pm on Jan 10, 2009 (gmt 0)

Thank you for your reply.

I want use button instead of javascript link. Can you tell me how can i use button instead of javascript "browse" link.


 7:08 pm on Jan 10, 2009 (gmt 0)

hm, <input type="button" onclick="Parent()" value="Close" /> instead of the 4th link. This is what you asked, right?


 8:02 pm on Jan 10, 2009 (gmt 0)

First link:

<a href="javascript: void(0);" id="browse">Browse</a>

I want browse button instead of this.


 8:18 pm on Jan 10, 2009 (gmt 0)

What does "browse" do?
You could do a form which passes no variable and has only a submit button, like this:

<form action="http://google.com" method="GET">
<input type="submit" value="some example" />

If you'd like to call a JS onclick event, then without form element and only onclick as I did with your 4th link.


 11:31 pm on Jan 10, 2009 (gmt 0)

When you clicked the browse link it was opening the window for upload a photo from your PC to Web. But i said that it's not working for me. Also yes, it calls a JS onclick event.


 6:17 am on Jan 11, 2009 (gmt 0)

javascript: void(0); will never open a file upload prompt. Anyway, you don't need JS for that it's neither recommended nor a good and reliable method. simple plain HTML and a simple php script will do it. Here, mess with this: [w3schools.com...]

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved