Check alle échte Black Friday-deals Ook zo moe van nepaanbiedingen? Wij laten alleen échte deals zien

[javascript] Bookmark bookmarklet howto

Pagina: 1
Acties:
  • 172 views sinds 30-01-2008
  • Reageer

  • Rekcor
  • Registratie: Februari 2005
  • Laatst online: 08-10 13:03
Hoe kan ik bookmarklet bookmarken m.b.v. javascript?

JavaScript:
1
window.sidebar.addPanel('Alert', 'alert(1)', '')


werkt niet in FF:
Fout: Invalid argument passed to window.sidebar.addPanel: Unsupported panel URL.
Bronbestand: file:///C:/PROGRA~1/MOZILL~1/components/nsSidebar.js
Regel: 91
FF wil namelijk dat de te bookmarken string begint met HTTP(s) / FTP...

  • Rekcor
  • Registratie: Februari 2005
  • Laatst online: 08-10 13:03
*schop*

  • DanielG
  • Registratie: Oktober 2005
  • Laatst online: 08-09 15:36

DanielG

i = 0x5f3759df - (i>>1); ☠₧ℳ🀪❣

Als ik handmatig in FireFox een bookmarklet toevoeg met URL: alert(1) dan werkt dit al niet en gaat hij automatisch naar [url="http://www.alert(1).com/"]http://www.alert(1).com/[/url].
Echter als ik hem toevoeg als URL: javascript:alert(1) dan werkt het wel.

Maar window.sidebar.addPanel('Alert', 'javascript:alert(1)', '') krijgt de zelfde foutmelding als eerst.

Als je in kijkt in het bestand nsSidebar.js bij regel 89 t/m 96 zie je:

JavaScript:
1
2
3
4
5
6
7
8
function sidebarURLSecurityCheck(url)
{
    if (!/^(https?:|ftp:)/i.test(url)) {
        Components.utils.reportError("Invalid argument passed to window.sidebar.addPanel: Unsupported panel URL." );
        return false;
    }
    return true;
}


Daar zie je bij de if dat hij test of de URL een geldige HTTP, HTTPS, of FTP url is.

Dus wat jij wilt gaat niet lukken gok ik zo.

[ Voor 7% gewijzigd door DanielG op 30-01-2008 11:10 . Reden: zooi over functie test() weg ]

http://xyproblem.info/