Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6679971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:25:14+00:00 2026-05-26T04:25:14+00:00

Is there now a length limit or other changes to how Safari 5 uses

  • 0

Is there now a length limit or other changes to how Safari 5 uses javascript bookmarklets as links in Bookmarks or the bookmark bar?

The bookmarklet below works in Safari 4, but in Safari 5 I get the error “Safari can’t use Javascript for this action.” It doesn’t seem to have anything to do with opening a new window, as the second script below works in 5 and opens a new window.

Are there other ways to use javascript for browser actions, either as bookmarklets or Safari extensions?

Update 10/07/11:

Bookmarklet now works in Safari 5 (but not 4) with one change, changing the 100% to 100%25:

javascript:s=document.getElementsByTagName('STYLE'); ex=document.getElementsByTagName('LINK'); d=window.open().document; /*set base href*/d.open();d.close(); b=d.body; function trim(s){return s.replace(/^\s*\n/, '').replace(/\s*$/, ''); }; function iff(a,b,c){return b?a+b+c:'';}function add(h){b.appendChild(h);} function makeTag(t){return d.createElement(t);} function makeText(tag,text){t=makeTag(tag);t.appendChild(d.createTextNode(text)); return t;} add(makeText('style', 'iframe{width:100%25;height:18em;border:1px solid;')); add(makeText('h3', d.title='Style sheets in ' + location.href)); for(i=0; i%3Cs.length; ++i) { add(makeText('h4','Inline style sheet'  + iff(' title="',s[i].title,'"'))); add(makeText('pre', trim(s[i].innerHTML))); } for (i=0; i%3Cex.length; ++i) { rs=ex[i].rel.split(' '); for(j=0;j%3Crs.length;++j) if (rs[j].toLowerCase()=='stylesheet') { add(makeText('h4','link rel="' + ex[i].rel + '" href="' + ex[i].href + '"' + iff(' title="',ex[i].title,'"'))); iframe=makeTag('iframe'); iframe.src=ex[i].href; add(iframe); break; } } void 0

Bookmarklet that fails in Safari 5 but works in 4:

javascript:s=document.getElementsByTagName('STYLE'); ex=document.getElementsByTagName('LINK'); d=window.open().document; /*set base href*/d.open();d.close(); b=d.body; function trim(s){return s.replace(/^\s*\n/, '').replace(/\s*$/, ''); }; function iff(a,b,c){return b?a+b+c:'';}function add(h){b.appendChild(h);} function makeTag(t){return d.createElement(t);} function makeText(tag,text){t=makeTag(tag);t.appendChild(d.createTextNode(text)); return t;} add(makeText('style', 'iframe{width:100%;height:18em;border:1px solid;')); add(makeText('h3', d.title='Style sheets in ' + location.href)); for(i=0; i%3Cs.length; ++i) { add(makeText('h4','Inline style sheet'  + iff(' title="',s[i].title,'"'))); add(makeText('pre', trim(s[i].innerHTML))); } for (i=0; i%3Cex.length; ++i) { rs=ex[i].rel.split(' '); for(j=0;j%3Crs.length;++j) if (rs[j].toLowerCase()=='stylesheet') { add(makeText('h4','link rel="' + ex[i].rel + '" href="' + ex[i].href + '"' + iff(' title="',ex[i].title,'"'))); iframe=makeTag('iframe'); iframe.src=ex[i].href; add(iframe); break; } } void 0

Bookmarklet that works with a new window:

javascript:var MTl=document.getElementsByTagName('script');for(var MTi=0,MTr,MTa=[];MTl[MTi];MTi++){if(MTr=MTl[MTi].getAttribute('src')){MTa[MTa.length]=MTl[MTi];}}if(!MTa.length){alert('This page does not use any external scripts');}else if(MTa.length==1){void(window.open(MTa[0].getAttribute('src')));}else{var MTw=window.open('');MTw.document.open();MTw.document.write('<html><head><title>External scripts for '+document.title+'<\/title><\/head><body><h1>External scripts for '+document.title+'<\/h1><p>');for(MTi=0;MTa[MTi];MTi++){MTw.document.write('<a href=\''+MTa[MTi].getAttribute('src')+'\'>'+(MTa[MTi].id?MTa[MTi].id:MTa[MTi].getAttribute('src').replace(/\/$/,'').replace(/^.*\//,''))+'<\/a><br>');}MTw.document.write('<\/p><\/body><\/html>');MTw.document.close();}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T04:25:15+00:00Added an answer on May 26, 2026 at 4:25 am

    I saw the same error from one of my bookmarklets. It turned out that it was improperly URL-encoded all along, and Safari 5.1 must just be more strict about that than previous versions. It looks like you have the same problem. Replace literal ‘%’ characters with ‘%25’ and see if you have better luck. (For example, change “width:100%;” to “width:100%25;“.)

    Too bad there’s such a cryptic error message.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There are lots of Fluent implementations out there now that work with Lambdas to
There are now so many ways to write windows apps, win32, MFC, ATL, .NET,
Now there is a subject that could be taken many ways. Hopefully I will
EDIT: There's now a doc page on this so this question is irrelevant, also
Or the concepts/best practices used there are now deprecated? I'm just starting to use
I just upgrade to Ubuntu Karmic 9.10 and there is now emphaty. The problem
I have data like below AAAAAA BBBBBB CCCCCC DDDDDD EEEEEE Now there is a
I have a NSMutableArray: NSMutableArray *temp = //get list from somewhere. Now there is
I am using html agility pack to parse html tabular information . Now there
I'm working with JBoss 4.2.1GA . As you might now there is a way

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.