views:

860

answers:

4

Question 1
step 1: i go to http://www.bloganything.net/731/cool-javascript-tricks-for-internet-browsers
step 2: on the address bar, i delete step 1 url, and enter javascript:document.getElementById('rsidebar').value='dsf' ; the whole part refresh . how to prevent page from refresh when executing javascript on address bar

Question2
any other technique to manipulate page dom without having access to the page source like question 1?

+5  A: 

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).

Jonathan Sampson
yes i know, i just thirst for knowledge. any other techinque can do it for local experience?
cometta
@David, updated my answer. See the first line ;)
Jonathan Sampson
=) i also know can use tool like what u mentioned. =) what if using naked browser without tool. possible? iframe ?
cometta
Yes, with an iframe you can execute javascript in the parent frame...
Ropstah
And regarding an answer to -your initial question- please see my answer ;)
Ropstah
A: 

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...

Ropstah
A: 

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.

T.J. Crowder
+3  A: 
  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 :)
Havenard
`javascript:void(stuff());` is the key to question one
gnarf
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.
Cleiton