DHTMl get current url?

[lua]
local html = vgui.Create(“DHTML”, music)
html:StretchToParent(0,0,0,0)
html:SetSize( 980, 626 )
html:OpenURL(“http://youtube.com”)
local endround = vgui.Create(“DButton”, music)
endround:SetFont(“Trebuchet22”)
endround:SetSize(200, 30)
endround:SetPos(5, 629)
endround:SetText(“Request End Round Music”)
endround.DoClick = function( button )
print(<–WHAT GOES HERE?–>)
end[/lua]

I need to get the url of a DHTML window but am having some trouble finding out how. Anyone able to point me the right way?

Edit: If you are here because you also have this problem please look at this solution: http://forum.facepunch.com/showthread.php?t=1308259&p=42224607&viewfull=1#post42224607

Try html.URL

Read this: https://github.com/garrynewman/garrysmod/blob/329e7979ea0cbb9dfbf9e89f27510baba791fd12/garrysmod/lua/vgui/dhtmlcontrols.lua

Returns nil

Edit:
I tried out dhtmlcontrols, OVerwritting OpenURL to display what is passed in, OpeningURL and FinishedURL they do not work properly, it seems I might be fucked out of luck here.

[LUA]
local html = vgui.Create(“DHTML”, music)
html:StretchToParent(0,0,0,0)
html:SetSize( 980, 626 )
html:OpenURL(“http://youtube.com”)

local HTMLControls = vgui.Create( “DHTMLControls”, html )
HTMLControls:SetHTML( html )

local hurl = HTMLControls.AddressBar:GetText()

local endround = vgui.Create(“DButton”, music)
endround:SetFont(“Trebuchet22”)
endround:SetSize(200, 30)
endround:SetPos(5, 629)
endround:SetText(“Request End Round Music”)
endround.DoClick = function( button )
print(hurl)
end
[/LUA]

Might work, haven’t really used it before.

Something broke the DHTML OpeningURL and FinishedURL along with a couple other things.

Currently, the only method that I know if is to run javascript (document.location.href)to a lua function that gives the url.

Try the “HomeURL” field of a HTML panel. https://github.com/garrynewman/garrysmod/blob/329e7979ea0cbb9dfbf9e89f27510baba791fd12/garrysmod/lua/vgui/dhtmlcontrols.lua#L80

[editline]17th September 2013[/editline]

Nevermind I doubt that’ll work, it’d be weird if a C function depended on a Lua function.

Why are you guys making this so complicated? Just find the meta table containing GHTML:WhateverFunctionOpensAURL and rewrite it so that when you call it, it writes the url you passed to it, to a variable.

Except you can navigate within the panel.

Exactly vex. I get what you are saying, darkness, just overwrite the OpenURL function and grab the url passed in and then send it on to the old function, I tried this and when you navigate in the html frame lua is never called. It seems the only way to solve this for now is with javascript sending back the current url.

The person gave me a solution using javascript here, even neatly packed in a class. Take a look: http://forum.facepunch.com/showthread.php?t=1308259&p=42224607&viewfull=1#post42224607