[Javascript] force to load window.open()

Hassan Schroeder hassan at webtuitive.com
Wed Jun 18 18:04:03 CDT 2003


noel.jean-baptiste at courrier.uqam.ca wrote:

> <A HREF="javascript:window.open('./ServletAcces?
> nomBase=etudiant','_self','status=yes');" >
> <IMG SRC="bouton.gif"/></A>
> 
> When i clik on the button for the first time the ServletAcces is 
> called.
> But the second time and more, the ServletAcces is not called because i 
> think it's the cach's browser.
> How can i do to force the link to call the ServletAcces each times it 
> is called ?
>  
> I kwow it is ok if i use _blank as attribute but i don't want to use 
> it.

I'm totally unclear why you're using JavaScript to open another page
in the same window, but as far as your immediate question -- you can
have `ServletAcces` return no-cache headers and/or append a unique
(timestamp) string to the URL to minimize browser caching.

Here's one approach to the latter:

<script type="text/javascript">
function init()
{
    var t = document.getElementById("s");
    t.search = t.search + "&date=" + Date.parse(new Date());
}

window.onload=init;
</script>

<a id="s"
    href="ServletAcces?nomBase=etudiant"
    onclick="window.open(this.href,'_self','status=yes');"
    >
<img src="bouton.gif"/></a>


(I put the onclick in there, though it's superfluous; the normal
link will open in the same window, unless you change the '_self'
to something else...)

HTH!
-- 
Hassan Schroeder ----------------------------- hassan at webtuitive.com
Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com

                           dream.  code.





More information about the Javascript mailing list