Results 1 to 3 of 3

Thread: url and back button

  1. #1
    Join Date
    Feb 2012

    url and back button

    I use ajax function (jquery).
    Is there any possibility to disable changing url in browser???

    My problem is that i loading content.html when im on mainpage and the link is changing in browser.
    For example mainpage.html#content
    I want to block it im intrested in situation: mainpage.html not mainpage.html#content becouse i want to disable back(browser) button only if its ajax event.

    Thanks for reply

  2. #2
    Join Date
    May 2006
    Somewhere behind your screen
    try using other elements instead of <a></a> to trigger your ajax functions. i mean

    <a href="#null" onclick="somefunction()">text</a>

    replace with let's say

    <img src="boobs.jpg" alt="big ones" onclick="somefunction()" />
    signature under construction

  3. #3
    Join Date
    Nov 2007
    You don't say why you are getting '#content' in the URL when you run AJAX to load a div with content...

    But... if you want to use <a>'s to run a JS function and have the URL not change, there are two methods available for you. I think both are cross-browser compatible, but it has been awhile since I've tested them in something other than FireFox. (Instead of using anchors, I do as Padonak suggests... I tend to use stylized <span>s for AJAXy text links.)

    Method 1: href="javascript:void(0);"
    function someFunction(){
      //blah blah
      alert('someFunction ran');
    <a href="javascript:void(0)" onclick="someFunction();">AJAXy Link Here</a>

    Method 2: add "return false;" to your onclick
    Notice in this one, if you remove the "return false", the URL will change to "test.html#goober", but it does not with the return false in place.
    function someFunction(){
      //blah blah
      alert('someFunction ran');
    <a href="#goober" onclick="someFunction(); return false">AJAXy Link Here</a>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Recent Articles