/    Sign up×
Community /Pin to ProfileBookmark

What’s the best browser Javascript trick that you know?

Yesterday (April Fools), I was playing around with Javascript in the address bar in Firefox. In case you didn’t know already, the Javascript gets executed in FF.

I was wondering if it’s possible to do something like the following for all of the elements on the page:

[CODE]javascript:void(document.getElementById(‘[I]a_very_important_element[/I]’).style.position=’absolute’)[/CODE]

I tried using getElementsByTagName(‘*’) and looping through the array, but it seems that only one command can be executed in the address bar.

to post a comment
JavaScript

8 Comments(s)

Copy linkTweet thisAlerts:
@moritanaApr 03.2011 — do that with jQuery.

this way you can (after you install the jquery plugin) do this:
[CODE]
$("body *").css("position","absolute");
[/CODE]

here's w3schools jQuery tutorial:

http://w3schools.com/jquery/default.asp
Copy linkTweet thisAlerts:
@cluefulApr 03.2011 — Is it getting foggy around here?
[CODE]javascript:(function(){ae=document.getElementsByTagName("*");for(var i=0,el;el=ae[i];i++){el.style.opacity="0.85";el.style.filter="alpha(opacity=80)"}})()
[/CODE]


Could induce nausea:
[CODE]javascript:(function(){ae=document.getElementsByTagName("*");for(var i=0,el;el=ae[i];i++){el.style.textDecoration="blink"}})()
[/CODE]
Copy linkTweet thisAlerts:
@linkskuauthorApr 03.2011 — @clueful: The second one is awesome! ?
Copy linkTweet thisAlerts:
@KorApr 04.2011 — do that with jQuery.

this way you can (after you install the jquery plugin) do this:
[CODE]
$("body *").css("position","absolute");
[/CODE]

here's w3schools jQuery tutorial:

http://w3schools.com/jquery/default.asp[/QUOTE]

No. Use JQuery only for complex applications, not for any simple JavaScript trick. You don't need a two tones press to break a nut, do you? :rolleyes:
Copy linkTweet thisAlerts:
@Jeff_MottApr 04.2011 — No. Use JQuery only for complex applications, not for any simple JavaScript trick. You don't need a two tones press to break a nut, do you? :rolleyes:[/QUOTE]

I vote yes, go ahead and use jQuery even for simple tricks like this. The reasoning is the same as for complex applications: Because jQuery lets us write shorter and simpler code.
Copy linkTweet thisAlerts:
@KorApr 04.2011 — I vote yes, go ahead and use jQuery even for simple tricks like this. The reasoning is the same as for complex applications: Because jQuery lets us write shorter and simpler code.[/QUOTE]
With the disadvantage of loading an elephant to create a mouse. And of understanding nothing about what JavaScript language is.

The main problem is that some people think that using JQuery exonerate them from learning JavaScript native language. Is this what you and JQuery want? If so, you are on the wrong side of the Force ?
Copy linkTweet thisAlerts:
@DanInMAApr 04.2011 — Excellant point KOR. I made the same mistake in my learning and often have to go back and re-learn certain things in JS because I concentrated way too much on Jquery due to ease of use and cross browser compatibility
Copy linkTweet thisAlerts:
@rnd_meApr 04.2011 — Not every one who uses jQuery is a fool, but it seems every fool uses jQuery...
×

Success!

Help @linksku 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 5.26,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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