7

If I go to this page and then delete the url from my browser's address bar, and then enter

javascript:document.getElementById('rsidebar').value='dsf';

The whole part refreshes. How can I prevent a page from refreshing when executing javascript from the address bar?

Also, are there any other techniques to manipulate a page without having access to the page source like the above method?

4 Answers 4

10

No, you cannot stop the user from manipulating the DOM.

You don't need to worry about people manipulating the DOM from the client-side. These changes only effect their local experience. They aren't actually affecting your site for other users.

You can easily manipulate the DOM using tools like Firebug, IEDeveloperToolbar, or Greasemonkey (Javascript engine).

Sign up to request clarification or add additional context in comments.

3 Comments

yes i know, i just thirst for knowledge. any other techinque can do it for local experience?
=) i also know can use tool like what u mentioned. =) what if using naked browser without tool. possible? iframe ?
And regarding an answer to -your initial question- please see my answer ;)
7
  1. When you do javascript:stuff(); and stuff() produces a return value, the whole page is replaced by it. You can prevent that by using javascript:void(stuff()); or javascript:stuff();void(0);
  2. Already answered by others :)

2 Comments

javascript:void(stuff()); is the key to question one
Havenard, you here?!?! A remark, you don't need to use parentheses when using void, it is an operator, so javacript:void doStuff(); is right too.
0

For Q1: I think this isn't possible because the browser runs every website in its own 'sandbox'

For Q2: I believe Firebug will let you execute javascript on any webpage...

Comments

0

Question 1: As the earlier responders said, nothing you can do I don't think.

Question 2: Check out bookmarklets, some very cool things can be done by running your own JavaScript against pages from various sites. People have written bookmarklets to highlight things on the page, put warning indicators next to links that will open in a new window, or go to aPDF, etc.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.