/    Sign up×
Community /Pin to ProfileBookmark

Changing URL without reload

Hi, I have an iframe on my page, and when buttons are clicked in my site changing the content of the frame, I want the buttons to change the URL, so it can be bookmarked and linked. However I do not want the URL change to force the entire page to reload.

I was given this code….

[QUOTE]

function loadsource()
{
var defaultPage = “home.html”;
var query = window.location.search.substring(1);
var pos = query.indexOf(‘=’);
if (pos > 0)
{
var frameSource = query.substring(pos+1);
window.frames[“canvas”].location = frameSource;
}
else
{
window.frames[“canvas”].location = defaultPage;
}
}

[/QUOTE]

Which allows the site to load up particular content in the frame based on url.
Then I got this code…

[QUOTE]

function change_parent_url(url)
{
document.location=url;
}

[/QUOTE]

Which changes the parent URL to whatever I put in. But with this, the entire page reloads, which defeats the point of having an iframe.

Finally, I stumbled upon this code, which I’m told will change the url without reloading, but I don’t know how it works or how to integrate it into the previous codes.

[QUOTE]

document.location.hash = “mylocation”;

[/QUOTE]

If anyone can help me understand this, thanks in advance.

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@JMRKERMar 29.2009 — See if you can modify post #4 of http://www.webdeveloper.com/forum/showthread.php?t=205686

to meet your needs.
×

Success!

Help @LampArtPro spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...