Safari Bookmarklet - accessing DOM I've tried following bookmarklets:


  javascript:document.body.style.width='50%';


or


  javascript:document.getElementsByTagName('body')[0].width='50%';


They both work in console, but not in bookmarklet. What is the reason?

They both work fine as Chrome's bookmarklets.

Also, this bookmarklet works fine (on HTML5 videos):


  javascript:document.getElementsByTagName("video")[0].playbackRate=2.5
Safari requires that a literal percent sign in a URL (%) be URL-encoded in a bookmarklet (%25...while it looks like that's just 25 added, the percent sign followed by two numbers is decoded to a literal percent sign). Also, the property is .style.width, not just .width.

Change your bookmarklet to this:

javascript:document.getElementsByTagName("body")[0].style.width='50%25';


I've confirmed this works in Safari v8.0.6 (OS X 10.10.3).