ID:1588395
 
(See the best response by Super Saiyan X.)
I need to be able to call a DM proc via javascript. The idea is to change the interface once the iframe inside of a browser control finishes loading.

Is this possible? May I have an example?
I think it's only possible using Topic[] calls.
As Jittai explained, JavaScript could call the Topic() in DM and send messages to procs that way. Any other way will be news to me.

Example:
client/Topic(href)
if(!href)return
var/list/href_list=params2list(href)
if(href_list["msg"])
var/msg=href_list["msg"]
mob.Say(msg)
mob/proc/Say(var/msg)
if(!msg)return
world<<"[src]: [msg]"

mob/verb/Say_Something(var/T as text)
if(!T)return
src<<browse({"<script>window.location='?msg=[T]'</script>"},"window=javascript")
src<<browse(null,"window=javascript")
Best response
You should be able to use JavaScript to call a verb, using the new features.

You use it exactly like the winset() proc, or the client-side .winset command, except you invoke it as a URL destination and it gets passed to client/Topic() when you click it - so be sure that if you overwrite client/Topic(), you call ..() and it'll just do the same as the winset functions.

var url = "byond://winset?command=";
var command = encodeURIComponent("verb name");
window.location = url + command;
Oh, thanks guys. Both are wonderful answers but I'll probably go with the winset command method. This sloves my problem.
I am very confused right now, I looked into the winset command stuff and for some reason, JavaScript seems to be disabled for me when I try to use it, I end up with no results.

When I attempt Ter's tutorial, if JavaScript is not enabled, you will be kicked from the game, and it so happens that I get kicked from the game.

When I do the old way to call Topic() it works, any suggestions?
have you tried to...enable JavaScript?

I dunno. I asked Ter to check this thread out when he has time.
I noticed SSX's version didn't work while the ID param was in the url. Here's what I did, although it's not complete.

EDIT: I noticed it doesn't always work though. Like if I navigate to MSN.com it never works. However if I go to byond.com, or many others it does work.
        getNavURL(url as text)
if(!browserLoading)
browserLoading=1
src.nav_url=url
src<<browse(null)
winset(src, "Browser.URL", "text=\"[text2url(src.nav_url)]\"")
winset(src, "Main.Child", "left=Browser")
src<<browse({"
<html>
<head>
<style>
body {
margin: 0px 0px;
}
</style>
<script>
function FinishedLoading()
{
window.location = "byond://winset?command=BrowserFinishedLoading";
}
</script>
<title></title>
</head>
<body bgcolor="#151515">
<iframe src="
[text2url(src.nav_url)]" width="790" height="518">
</iframe>
<script>window.onload = FinishedLoading</script>

</body>
</html>
"}
)
while(browserLoading)
sleep(1)
//RefreshIconShow

BrowserFinishedLoading()
browserLoading=0
I am assuming this uses Internet Explorer still, and I have JavaScript enabled for Internet Explorer.

For some reason I can use JavaScript for certain things but not other things.

It seems that Remvoving the id from the url makes it work, but Ter's example still doesn't work for me at all.
Out of curiosity what does Ter's example look like?
Pretty sure he's talking about this:

http://www.byond.com/forum/?post=1581490#comment10298209

or this:

http://www.byond.com/forum/?post=1477869#comment8506256

The second one is kind of weak in a few respects, though.
The second one :o