WinFuture-Forum.de: User.js - Fehlfunktion? - WinFuture-Forum.de

Zum Inhalt wechseln

Nachrichten zum Thema: Entwicklung
Seite 1 von 1

User.js - Fehlfunktion? läuft aber tut nicht :-(


#1 Mitglied ist offline   fineliner 

  • Gruppe: aktive Mitglieder
  • Beiträge: 106
  • Beigetreten: 14. Januar 05
  • Reputation: 0

  geschrieben 17. Januar 2007 - 10:25

habe ein User.js umgeschrieben das bilder im browser maximiert auf das Fenster/Höhe/Breite

wenn ich die entscheidende zeile:

window.document.all.innerHTML = '<html><head><title>Bild<\/title><script type="text\/javascript"> var fit_modes = ["cursor:move;display:block; margin:auto auto", "display:block;max-width:100%;max-height:100%;margin:0 auto;padding:0;cursor:move", "display:block;width:100%;height:auto;margin:0 auto;padding:0;cursor:e-resize", "display:block;width:auto;height:100%;margin:0 auto;padding:0;cursor:s-resize;" ]; var nr=0; function change(nrn){nr = nrn;document.images[0].style = fit_modes[nrn];}<\/script><\/head><body><a href="java script:change((nr+1)%4)" ><img src="'+document.images[0].src+'" style="cursor:move;display:block; margin:auto auto" alt="zoff"><\/a><\/body><\/html>';

wohlgemerkt unter opera mit "javascript"-protokoll starte funktioniert es einwandfrei

aber das untenstehende User.js läuft nicht und wirft bei mir auch keine Fehler aus.

bitte helft mir: "was läuft hier falsch?"

// ==UserScript==
// @name Autosizer
// @author Arve Bersvendsen (edited by fineliner)
// @namespace http://virtuelvis.com/
// @version 1.0.2
// @description  Enhance image viewing in Opera by adding five
//			different sizing modes to images: "Original",
//			"Shrink to Fit", "Maximize", "Fit to Width" and
//			"Fit to Height".
// @ujs:category browser: enhancements
// @ujs:published 2005-10-22 20:25
// @ujs:modified 2007-01-15 23:53
// @ujs:documentation  http://userjs.org/scripts/browser/enhancements/autosizer
// @ujs:download  http://userjs.org/scripts/download/browser/enhancements/autosizer.js
// ==/UserScript==


if ((window.location.href.match(/^.*\.(jpe?g|bmp|gif|png)$/i)) && (document.images.length==1) && document.body.childNodes.length == 1)
  {
window.document.all.innerHTML = '<html><head><title>Bild<\/title><script type="text\/javascript"> var fit_modes = ["cursor:move;display:block; margin:auto auto", "display:block;max-width:100%;max-height:100%;margin:0 auto;padding:0;cursor:move", "display:block;width:100%;height:auto;margin:0 auto;padding:0;cursor:e-resize", "display:block;width:auto;height:100%;margin:0 auto;padding:0;cursor:s-resize;" ]; var nr=0; function change(nrn){nr = nrn;document.images[0].style = fit_modes[nrn];}<\/script><\/head><body><a href="java script:change((nr+1)%4)" ><img src="'+document.images[0].src+'" style="cursor:move;display:block; margin:auto auto" alt="zoff"><\/a><\/body><\/html>'; 
}

0

Anzeige



#2 Mitglied ist offline   Rika 

  • Gruppe: aktive Mitglieder
  • Beiträge: 11.533
  • Beigetreten: 11. Juni 03
  • Reputation: 2
  • Geschlecht:Männlich

geschrieben 17. Januar 2007 - 11:35

Vielleicht weil du dich enorm darauf verlässt, daß dein Webbrowser diverse Fehler anderen Browser emuliert? document.images, document.body, document.all, das gibt's doch alles gar nicht.
Konnichiwa. Manga wo shitte masu ka? Iie? Gomenne, sonoyouna koto ga tabitabi arimasu. Mangaka ojousan nihongo doujinshi desu wa 'Clamp X', 'Ayashi no Ceres', 'Card Captor Sakura', 'Tsubasa', 'Chobits', 'Sakura Taisen', 'Inuyasha' wo 'Ah! Megamisama'. Hai, mangaka gozaimashita desu ni yuujin yori.
Eingefügtes Bild
Ja, mata ne!

(For sending email please use OpenPGP encryption and signing. KeyID: 0xA0E28D18)
0

#3 Mitglied ist offline   fineliner 

  • Gruppe: aktive Mitglieder
  • Beiträge: 106
  • Beigetreten: 14. Januar 05
  • Reputation: 0

geschrieben 17. Januar 2007 - 12:02

das könnte es natürlich VIELLEICHT sein aber dagegen spricht, dass

die if-bedingung alleine funktioniert (getestet mit if--> alert)

das heißt es muss an der document.all.innerHTML=... liegen

die aber eigentlich auch funktioniert (getester mit java script:document.all.innerHTML=....)

bitte um korrektur und hilfestellung :)
0

#4 Mitglied ist offline   fineliner 

  • Gruppe: aktive Mitglieder
  • Beiträge: 106
  • Beigetreten: 14. Januar 05
  • Reputation: 0

  geschrieben 17. Januar 2007 - 21:10

gelöst: sauber ist immer besser

if ((window.location.href.match(/^.*\.(jpe?g|bmp|gif|png)$/i)) && (document.images.length==1) && document.body.childNodes.length == 1)
{
if (document.title != 'Picture-Autosizer'){
window.document.write('<html><head><title>Picture-Autosizer<\/title><script type="text\/javascript"> var fit_modes = ["cursor:move;display:block; margin:auto auto", "display:block;max-width:100%;max-height:100%;margin:0 auto;padding:0;cursor:move", "display:block;width:100%;height:auto;margin:0 auto;padding:0;cursor:e-resize", "display:block;width:auto;height:100%;margin:0 auto;padding:0;cursor:s-resize;" ]; var nr=0; function change(nrn){nr = nrn;document.images[0].style = fit_modes[nrn];}<\/script><\/head><body><a href="java script:change((nr+1)%4)" ><img src="'+document.location.href+'" style="cursor:move;display:block; margin:auto auto" alt="zzoff"><\/a><\/body><\/html>');
window.document.close();
}
}

obwohl gan dreckig auch funktioniert :-P :

if ((window.location.href.match(/^.*\.(jpe?g|bmp|gif|png)$/i)) && (document.images.length==1) && document.body.childNodes.length == 1)
{


window.location.href='java script:'+ 'window.document.write =' +"'"+ '<html><head><title>Bild<\/title><script type="text\/javascript"> var fit_modes = ["cursor:move;display:block; margin:auto auto", "display:block;max-width:100%;max-height:100%;margin:0 auto;padding:0;cursor:e-resize", "display:block;width:100%;height:auto;margin:0 auto;padding:0;cursor:s-resize", "display:block;width:auto;height:100%;margin:0 auto;padding:0;cursor:move" ]; var nr=1; function change(nrn){nr = nrn;document.images[0].style = fit_modes[nrn];}<\/script><\/head><body><a href="java script:change((nr+1)%4)" ><img src="' +"'"+'+ document.location.href+' +"'"+ '" style="cursor:move;display:block; margin:auto auto" alt="zoff"><\/a><\/body><\/html>' +"'";

}

h.a.n.d. fineliner ;)
0

Thema verteilen:


Seite 1 von 1

1 Besucher lesen dieses Thema
Mitglieder: 0, Gäste: 1, unsichtbare Mitglieder: 0