Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Greasemonkey script help

Name: Anonymous 2007-11-30 21:15

Ok /prog/. I'm trying to make a Greasemonkey script to prevent me from accidentally leaving a certain page.

How would I go about doing this? I'm pretty sure I have to use 'window.onbeforeunload', but I'm not really sure how.

This is what I currently have, which does not work.

window.onbeforeunload = confirmExit;
  function confirmExit()
  {
    return "Are you sure you want to exit this page?";
  }

What am I doing wrong?

Name: Anonymous 2007-11-30 21:49

awesome troll

Name: Anonymous 2007-11-30 22:03

>awesome troll

Seriously though, I'm not a troll. After some testing, I found this works in IE, but not in Firefox (which is what I need).

Any idea how I could make this work?

Name: Anonymous 2007-11-30 22:05

Use IE, problem solved.

Name: Anonymous 2007-11-30 22:10

window.onbeforeunload=function(){
 var f=arguments.callee;
 window.onbeforeunload=function(){f();};
 return false;
};

Name: Anonymous 2007-11-30 22:21

I can't use IE, the point of using FF is so this script can load on certain pages automatically (via Greasemonkey).

Name: Anonymous 2007-11-30 22:23

@5

Doesn't seem to work =/

Name: Anonymous 2007-11-30 22:29

>>3
ok then... don't return a string. there is a function for opening up a combo.

Name: Anonymous 2007-11-30 22:33

>>8
Sorry... what?

I have little to no experience with JS.

Would you mind posting an example code that would work?

Name: Anonymous 2007-11-30 22:36

On the assumption this isn't a troll, confirm() will do what you need.

Name: Anonymous 2007-11-30 22:39

>>10

No, I'm not. I'm just a friggin noob.

So would I add that at the beginning or at the end, or where?

Name: Anonymous 2007-11-30 22:40

I don't know if it works, but confirm() opens up a dialogue box. experiment a little.

Name: Anonymous 2007-11-30 22:41

also, it returns a value, true or false. And the returning value of a function in an event may represent the cancelation of the event, in this case, closing the window.

Name: Anonymous 2007-11-30 22:47

>>13

I'm still lost. Assuming you don't want to spend another hour explaining how this works, maybe you could just post a working snippet of code?

Name: Anonymous 2007-11-30 22:50

I also tried this, which didn't work

window.onbeforeunload = function (oEvent) {  
        oEvent.returnValue = "blah";  
    }  
    if (typeof evt == 'undefined') {  
      evt = window.event;  
    }  
    if (evt) {  
      evt.returnValue = message;  
    }  
    return message;  
  }  

Name: Anonymous 2007-11-30 22:59

OP here, something interesting...

the code in >>15 sort of works -- the box pops up when the page LOADS, instead of when you attempt to leave.

Name: Anonymous 2007-11-30 23:05

Any help at all for a noob who just wants to prevent himself from accidentally leaving a page? =/

Name: Anonymous 2007-11-30 23:06

lrn2XPCNativeWrapper

Name: Anonymous 2007-11-30 23:08

window.onbeforeunload = function(){
 return prompt("You are a fucking idiot.");
}

Name: Anonymous 2007-11-30 23:09

>>18

Look, instead of directing me to do possibly hours of research just to get a measly ten line piece of code to work, couldn't you just post a working one in about 60 seconds?

Name: Anonymous 2007-11-30 23:11

>>19

Good try, but it doesn't work either.

Name: OP 2007-11-30 23:16

Would really appreciate some help right about now.

Name: Anonymous 2007-11-30 23:24

The following works in FF as a standalone HTML page, but I can't get it work through Greasemonkey. Any suggestions?


<script language = javascript>

window.onbeforeunload = function (evt) {
  var message = 'Are you sure you want to leave?';
  if (typeof evt == 'undefined') {
    evt = window.event;
  }
  if (evt) {
    evt.returnValue = message;
  }
  return message;
}


</script>

Name: Anonymous 2007-11-30 23:57

Name: Anonymous 2008-11-10 19:50

nigger

Name: Anonymous 2009-03-06 11:16

Accidentally LAUNCHED IT A   meme obviously has   to parse something   hence THERE IS   I just compiled   the program and   nothing happens He   then calls his.

Name: Anonymous 2010-11-14 12:50

Name: Anonymous 2013-01-18 23:23

/prog/ will be spammed continuously until further notice. we apologize for any inconvenience this may cause.

Name: Anonymous 2013-08-31 23:11



(             `ヽ
 )  :  戦  せ    ノ          , '´ ̄ ̄ ̄ ̄`ヽ
(   :  争      (  :.       |   こ   え
ノ   :  だ       ノ  ::     / ./  と
|     :  わ      (  ::::::    / , ,'   :  え
.\             ) ::::     | / |     :  ら
  >ー───-、    r'  ::    / .,' '、    :  い
  /_,,..-─-、:::\ \ |  :    ,'  |::::::/\
        \:::\. ∨ -───|  ,'::::/   `' ー┐  _ノ
          ,>、|o|         !o//  `' 、 (   _ノ
:::::.......   , '/         /`          ヽ )ノ   ...:::::
   ::::...,' /   /      ,'    |    、 ヽ.  '´  ...::::
     ;' ,'   .,.'    /   ,!   ,ハ    ハ   ',  ', ;
::::: :::.....  |   /   /|メ、_,./!   /∠._ / |    |  | {
    ;l /  ,'   /'´ ̄` :::|  ,.'::::'´ ̄`ヽ|  / .|  | ..:::::.....::::::.....
     ; ,'   /! ./!  ;'´,ハ ::!/u:: ;'´,ハ  !/  !  | {
    .l |  / .| /.人 弋__ノ ::::::::::::: 弋__ノ ノ / ,'   ! l|    .......::::
 :::... } !/  !/.!:|w     ,      xw|/ /   | } ...:::::
    ::::... } |:::|::| u            u  |   ,'    .| 
 :::::.....    { ,' !人    rァ─-、    ,ハ  |   i  | l|
    ::::....../  |  |> 、 `ー‐‐┘  /.!  |  |  | l  :::::.......
      ; /  |  | 、ヽ ヽ.,___,. イ、  |  ,!   |  |      ::::...
      ;'.,'   /|  |     r!    / ヽ'  ハ  |  | {
::::::::....  l .! .,' |  |-─//|  /   / /\   !  | } :::::...
       .|  /| /  /  /[]\  //   ´ ̄`ヽ | ;    :::::....

Name: Anonymous 2013-09-01 0:42



            __,,.. --──- 、..,,_        ,. -──────
        ,. ''"´     '⌒)_,.-、  `';       ,'
    ,. -‐<       、_,,... ---──'-、      i 何これ
   ;'     `ヽ._,,..ゝ-<.,__,,..-‐-、,    ';ヽ.    |
   !   (⌒ヽノ !   ! ,' /!  ! `''ー、イ  !   ! キュウリじゃない
   ';       八 ,ゝ、_」ィ!__/ .!  ;' ! ; ヽ./  ∠.._
   ',   ',  /  `i ;'´;'ハ  └、;_,.ィ /   ハ    `'' ー----------‐
    i   Y`ヽ/!_,!i !_,ソ    !ハ`yiヽ、/ /
   ,'   /  .!  'ひ   ..::::.. '-'_ノi Y  ',  なんか苦い
 _.ノ   ,ヘ._  ',  '、   ,.-‐-、   ''!八  ! 
  `( r'  )`ヽヽ  )、 し--‐’ ,.,イ  ! )ノ    _)
   )' />‐‐'<Yヽ、`' T7"´ノレヘノ (     ,.:'";';
    ,.':::/     ヽr、 \.」 `!」ヽ.       ノ_);':;'
    /:::;' /こコ  iヽヘ/ム、!」,  i     ,.'´_;',:;'
   ;':::7 /   !  ト、    ハ   V !.  ,..-r'つ'、ヾ'
    i:r!        ,'  ヽ、 ○ / !//  !/;'(__,ソ
   !/`  r-   イ    `F'   !'´    !、__ノ!
  /   '    !  _,,..イ  `ゝ、i       _,:'

Name: Anonymous 2013-09-01 2:14



                              、| ll | | || l| | | ll ||
                 r─r、          ミ  マ ワ
            [「 ̄|7ヽ|  |_|   , --‐ァ、  三 回転される!?
       rァ‐-、 「!  |] / |  / | /  / | |  彡,
        「|   \| __」 '-┴-'<7  // ./7   / l| | | ll || | ll | | ||
       レ' ̄>'"´:.:.:.:.:.:.:.:.:..:.:.:.:`゙'<´>'/
     , -‐ァ/:.:,.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.';.:.:.:.:.:.\「\ ___
    r'///:.:.:./:.:.:|:.:.:.:.:.:!:.:.:.;.:.:.:.:!:.:.:.:.:.:.:.:':,  `゙''ー‐ヽ、
   .// /,':.:.:.;':.:.:.:.ハ:.:.:.:/|__/ー-;ハ:.:.:.:.:.:.:.:.:|\     |]
   |7  |_|:.:.:.|:.:.:イ |/  '´ ̄`。|:.:.:.:.!:.:.:.:!  ` ー-、 |」
   |' .//|:.:.:.|/ァ'´` .      ゙O:.:.:|:.:.:.:|      |/
   | .// !::.:.:o:.i'゚   rァ─-、  /:.:.:.:;':.:./:!      /|
   |/   ',:.:.:.:.:.!、  !    ノ ,.':.:.:.:.//:/    / /!
   /|    |、:.:.:.:|:.:> 、,_  /:.:.:/´:./   <,__/_」
  / |    |:.\:.|:.:/.:.r‐ァ|/:.:.:./ァ'"´ ̄`77、
 ,' /|    '、:.:.:\|>'"´r‐<´ ./    / /::::\    
 ! |.」   r<}] ̄`Y 7´ ̄[{./    //::::::::::::::\
 |/    ト、/{」__ンく.,__|}   //:::::::::::::::::::::::::::'.,
      /::[|  /:.:.:.:.:)\   /_/|::::::::::::::::::_;rェ‐-、ノ  でもちょっと
       /:::::::l]_/|:.:.ン´:::::::::\/_/八:::::::::rァ'´ ̄\]       嬉しそう
    rヘ:::::::/:::::::::|/::::::::::::::::::::;:::::::::::/ >-へ    \

Don't change these.
Name: Email:
Entire Thread Thread List