main
side
curve
  1. Welcome to the new boards! Details here!

Using JavaScript to make the markup codes more versatile.

Discussion in 'Communications' started by Lobot_Omy, Aug 8, 2001.

Thread Status:
Not open for further replies.
  1. Lobot_Omy

    Lobot_Omy Moderator Emeritus star 6 VIP - Former Mod/RSA

    Registered:
    Jul 9, 2001
    Yep, I've noticed. :D
     
  2. jasman

    jasman Administrator Emeritus star 4 VIP - Former Mod/RSA

    Registered:
    Aug 29, 1998
    Well, I finally decided to let you guys see it!

    Click [link=javascript:alert('Access%20Denied')]HERE[/link] for the SPEEDO pic!
     
  3. Darth Gleng

    Darth Gleng Jedi Youngling star 3

    Registered:
    Jun 17, 1999
    [link=javascript:alert("This");alert("is");alert("getting");alert("silly!");]lol indeed![/link]

    Edit: tried something else but it didn't work! ;)
     
  4. Lobot_Omy

    Lobot_Omy Moderator Emeritus star 6 VIP - Former Mod/RSA

    Registered:
    Jul 9, 2001
    Darth Gleng, you can use ' instead of \", so that way you can save character space. ;)

    Edit: Darth Gleng, you can add some of your JavaScript codes if you want. These are the only ones I could think of that could be useful around here.

    [link=javascript:confirm('Is%20this%20too%20much?')?alert('It\'s%20too%20much.'):alert('Alright,%20it\'s%20not.')] Clickidy click [/link]
     
  5. Darth Gleng

    Darth Gleng Jedi Youngling star 3

    Registered:
    Jun 17, 1999
    I was trying to squeeze some DHTML into one line but it was doomed to failure from the start! ;)

    As for my scripts, well they're hardly useful but here's the ones I've used so far anyway ;)

    To do the multiple alert box thing from my post above, you simply separate the alert() commands with semicolons, like so:

    javascript:alert("This");alert("is");alert("getting");alert("silly!");

    My prompt from the last page, uses a variable (created with var) to store whatever is typed into the prompt() box, in this script I have called my variable stuff.

    The script goes something like this:

    var stuff = prompt("Type something!");
    alert(stuff);


    Where I have typed "Type something!" just tells the initial prompt box to display the question.

    This unfortunately has to be squished down into one line, again separating with the semicolon, eg:

    javascript:var stuff = prompt("Type something");alert(stuff);

    Remember to always substitute the spaces for the the space character code (%20 or whichever you use) so it'll end up looking like this:


    javascript:var%20stuff%20=%20prompt("Type%20something");alert(stuff);


    There ya go!





    Actually now I've thought about it:


    javascript:alert(prompt("Type something!"))


    would have been easier! ;)
     
  6. Lobot_Omy

    Lobot_Omy Moderator Emeritus star 6 VIP - Former Mod/RSA

    Registered:
    Jul 9, 2001
    You don't have to put var in order to create a variable you can just state the name and assign the value to it. It makes it shorter. If you put %20 instead of spaces then it will only work in IE, not Netscape, but I don't know how many people here actually use Netscape.

    Thanks for sharing the codes. :)
     
  7. Darth Gleng

    Darth Gleng Jedi Youngling star 3

    Registered:
    Jun 17, 1999
    Thanks [hl=#45446c]Lobot_Omy[/hl]! ;)

    [link=javascript:t=new%20Date();alert("It\'s%20"+t.getHours()+":"+t.getMinutes());]I wonder what time it is??[/link]

    Hehehe...here's the script!


    javascript:t=new Date();alert("It\'s "+t.getHours()+":"+t.getMinutes());]I wonder what time it is??


    Of course, remembering your favourite space substitute! ;)
     
  8. jasman

    jasman Administrator Emeritus star 4 VIP - Former Mod/RSA

    Registered:
    Aug 29, 1998
    It's probably not necessary to post the code. If you place your cursor over the link, the code appears at the left end of the status bar at the bottom of the window. I always look there before clicking on a link.
     
  9. yodaboy

    yodaboy Jedi Master star 5

    Registered:
    Feb 5, 2001
    [link=javascript:alert("WoW");alert("thisstuff");alert("isgetting");alert("reallycomplicated");alert("butcool");]look ma[/link]

     
  10. Gandalf the Grey

    Gandalf the Grey Jedi Knight star 6

    Registered:
    May 14, 2000
    It is necessary if we want to cut and paste.
     
  11. jasman

    jasman Administrator Emeritus star 4 VIP - Former Mod/RSA

    Registered:
    Aug 29, 1998
    yodaboy,

    You need to add the space substitutes between 'is' and 'getting' and between 'really' and 'complicated'.

    Now get rid of that last semicolon.

    Don't worry, you'll get there! :D

    ______________

    Gandolf, sorry, didn't think of that.

    :(
     
  12. Darth-Stryphe

    Darth-Stryphe Former Mod and City Rep star 6 VIP - Former Mod/RSA

    Registered:
    Apr 24, 2001
    So what are the rules that define the limitations in which javascript can operate on these boards?
     
  13. jasman

    jasman Administrator Emeritus star 4 VIP - Former Mod/RSA

    Registered:
    Aug 29, 1998
    When in doubt, ask a moderator. All of the examples shown on this thread so far are, IMO, perfectly acceptable. Using them could be a lot of fun, something to do when it gets kinda slow around here. :)

    If you're thinking of using a javascript code, post it here first.

    Also, remember that this kind of thing is best if it isn't over-used.
    Even this can get [link=javascript:alert('boring')] [face_plain] [/link] if used too much.


    (click the face)

    OK, how do you get the smilies to work in the link?

    [face_blush]

    It worked!

    :D


     
  14. Darth Gleng

    Darth Gleng Jedi Youngling star 3

    Registered:
    Jun 17, 1999
    As long as they're not offensive and they don't kill the board in any way, I can't see there being a problem :)
     
  15. Lobot_Omy

    Lobot_Omy Moderator Emeritus star 6 VIP - Former Mod/RSA

    Registered:
    Jul 9, 2001
    Yeah, as long as they don't mess up browsers or do any other funny things they should be fine, in my opinion.

    Edit:
    For my link above with splitting responces.

    Code: javascript:confirm('your text')?alert('your text'):alert('your text')

    Without the spaces of course.
     
  16. Valiowk

    Valiowk Jedi Grand Master star 6

    Registered:
    Apr 23, 2000
    Hmmm, I wonder if this should be posted in Info Threads? It seems to me that it might be useful, but we'll need to tidy this up first. :)
     
  17. yodaboy

    yodaboy Jedi Master star 5

    Registered:
    Feb 5, 2001
    [link=javascript:alert('I%20finally%20got%20it%20to%20work!!')]look ma[/link]


    [link=javascript:confirm('can%20I%20do%20it?')?alert('yes'):alert('no')]no hands![/link]
     
  18. Lobot_Omy

    Lobot_Omy Moderator Emeritus star 6 VIP - Former Mod/RSA

    Registered:
    Jul 9, 2001
    I tried to pick useful codes. Like that link opening in a new window when you just left-click it and the scrolling around the page code. But other than that I can't come up with anything else. There's so many problems that one can run into using JavaScript around here, since the amount of characters in the link tag is limited and no spaces are allowed.

    Scrolling to the location of page that the user wants to go to:

    Code: javascript:a=prompt('Where%20to?');navigator.appName=='Netscape'?scrollTo(0,parseInt(a)):scroll(0,parseInt(a))

    Example: [link=javascript:a=prompt('Where%20to?');navigator.appName=='Netscape'?scrollTo(0,parseInt(a)):scroll(0,parseInt(a))] Go To [/link]

     
  19. Lobot_Omy

    Lobot_Omy Moderator Emeritus star 6 VIP - Former Mod/RSA

    Registered:
    Jul 9, 2001
    Message before leaving the page:

    code: javascript:alert('Your message');location='URL goes here'

    Example: [link=javascript:alert('Bye%20bye.');location='http://boards.theforce.net/board.asp?brd=10006'] Communications [/link]

    Edit: Or better yet...
    Ask if user really wants to leave the page before leaving:

    code: javascript:if(confirm('Are%20you%20sure?')){location='URL goes here'}

    Example: [link=javascript:if(confirm('Are%20you%20sure?')){location='http://boards.theforce.net/board.asp?brd=10006'}] Communications [/link]

     
  20. Darth Gleng

    Darth Gleng Jedi Youngling star 3

    Registered:
    Jun 17, 1999
    Not a javascript but still handy anyway :)

    I just used this in another thread. Linking to a directory on the users machine.

    Enter the path to a directory as the link and it will open in the browser window. Not much use, but handy if you're trying to give tech support via the message board :)

    Example:

    [link=C:\]Here's your C:\ drive![/link]
     
  21. JediMaster22

    JediMaster22 Jedi Knight star 8

    Registered:
    Oct 15, 1999
    I used it at the library once, ok... they hide their drives.... and this javascript alone opened it.

    Security Flaw of Windows, eh :p
     
  22. Lobot_Omy

    Lobot_Omy Moderator Emeritus star 6 VIP - Former Mod/RSA

    Registered:
    Jul 9, 2001
    I'm bored so here's a useless way to use JavaScript here:

    Linking to another page:

    code: javascript:location='URL goes in here'

    [link=javascript:location='http://www.theforce.net']Example[/link]
     
  23. Phantom_Catfish

    Phantom_Catfish Jedi Master star 4

    Registered:
    Sep 10, 2001
    I cant get a pic to show! I have tried the HTML but i cant get it to work.
     
  24. Lobot_Omy

    Lobot_Omy Moderator Emeritus star 6 VIP - Former Mod/RSA

    Registered:
    Jul 9, 2001
    What pic are you talking about?
     
  25. Night4554

    Night4554 Jedi Knight star 5

    Registered:
    Oct 9, 2000
    well i assume you mean you used ezcodes where you put the tags in like this:

    [image=http://www.images.com/image1.jpg

    (but adding a "]" on the end, i left it out to display the coding)

    HTML does not work on these forums so this would not work:

    <img src="http://www.inages.com/image1.jpg">

    and of course certain servers like angelfire and geocites won't display the images no matter what cause they're stoopid ;)

    hope i've cleared this up for ya

    ¤Night
     
Thread Status:
Not open for further replies.