Ulysses

General => Developers Corner => Topic started by: krooks on March 24, 2011, 01:41:20 PM

Title: motdmenu.lua "back" button
Post by: krooks on March 24, 2011, 01:41:20 PM
Is there some (relatively simple) way for me to add a back button to this file?

I like that the menu allows for us to specify web pages, and I thought it would be nice to link to places like google from my main motd. This way the players on my server would have another option (other than steam's clunky browser), to browse the web.
Title: Re: motdmenu.lua "back" button
Post by: Megiddo on March 24, 2011, 01:50:40 PM
There's some way to do it, if only using the javascript command for back. Otherwise I think you can catch each new page in a callback somewhere to store them.
Title: Re: motdmenu.lua "back" button
Post by: krooks on March 25, 2011, 09:27:06 AM
Yeah I thought of using a PHP or Java way to go about this, but I was getting confused, because I would have to run it in an iframe, if linking to Google, then I didn't know how to go about targeting the iframe with java/php
To clarify, I'm not looking to go back to the main motd page necessarily, I could do that with java/php no problem. But rather I am trying to be able to browse google and go back to your google search after visiting the desired page.

The Lua idea you mentioned sounds a bit more in-depth than I anticipated, having to store and callback pages

Thanks for the pointers though
Title: Re: motdmenu.lua "back" button
Post by: JamminR on March 25, 2011, 02:11:31 PM
Though I don't know the javascript 'document' properties well enough to help directly, if you could find how to get javascript to act on 'targets', just as the HTML anchor tag can (http://www.w3schools.com/tags/att_a_target.asp), I would think it possible to name the frame, and have the javascript perform the 'back' action on it.
Title: Re: motdmenu.lua "back" button
Post by: krooks on March 26, 2011, 10:42:49 AM
Yeah, I'm not really a java guy either  ;D
If I come up with something I'll be sure to let everyone know
Title: Re: motdmenu.lua "back" button
Post by: EraYaN on March 30, 2011, 11:11:23 AM
if you use and iframe

for setting it
document.all.FrameName.src=url;

and for the back button
frames['framename'].history.back();

(you should give your iframe a name AND id
Title: Re: motdmenu.lua "back" button
Post by: krooks on April 01, 2011, 06:14:58 PM
Thank you! I will give it a try the next chance I get!
Title: Re: motdmenu.lua "back" button
Post by: JamminR on April 01, 2011, 06:55:27 PM
I at least remembered it was going to be a 'document' property. See how helpful I was? :P (Yes folks, I'm joking)
Title: Re: motdmenu.lua "back" button
Post by: krooks on April 11, 2011, 05:48:31 PM
Hmm, I'm sorry to have to come back and ask a very simple question, but I really do.
I've searched google for a working implementation of the provided code, and code's like it (thanks again EraYaN), but I couldn't find anything that worked. and I have exhausted my own knowledge.

I'm actually surprised with myself because I usually don't have this hard of a time implementing pre-made java/php on my sites, and I do it a lot.

If you, or anyone has an extra minute to show how it might look, it would be a terrific help. no need to add all the body/head elements, obviously.

No rush.
Title: Re: motdmenu.lua "back" button
Post by: edk141 on April 12, 2011, 02:06:07 AM
This won't be right, but something like
Code: [Select]
<iframe id="browser" src="/frame.html"></iframe>
<a href="#" onclick="document.getElementById('browser').contentWindow.history.back();">go back</a>
Title: Re: motdmenu.lua "back" button
Post by: krooks on April 13, 2011, 08:23:43 AM
aaah ok, so thats how the link is set, thanks for pointing me in the right direction!
Title: Re: motdmenu.lua "back" button
Post by: krooks on April 16, 2011, 12:03:51 PM
edk141 I was still having issues with the code,  but thanks to you it gave me a starting point for my google searches.
I ended up using this code:
Code: [Select]
<input type='button' value='< BACK' onclick='Frame_Name.history.back()'>
<input type='button' value='FORWARD >' onclick='Frame_Name.history.forward()'>
and just gave the iframe a name (Frame_Name) and id that were the same.

So theres how ya do it folks! (for future reference)