*RaCeR^ Posted April 10, 2017 Share Posted April 10, 2017 Hello everybody, i'm here for help with a little problem. I'm trying to create a Youtube Browser to play songs for the whole server. but Link does not update itself as it should. Can anyone tell me a function that does when I click the link it automatically changes the URL in the text bar? Below this to change when you click a button. I wanted him to change alone. function geturl() if source == CINEMA.button[1] then guiSetText(addressBar,getBrowserURL(theBrowser)) end end addEventHandler("onClientGUIClick",root, geturl) Can somebody help me ? Thx s2 Link to comment
Mr.Loki Posted April 10, 2017 Share Posted April 10, 2017 https://wiki.multitheftauto.com/wiki/OnClientBrowserNavigate Link to comment
*RaCeR^ Posted April 10, 2017 Author Share Posted April 10, 2017 (edited) idk how to use this command, u can show me some examples ? plz :c Edited April 10, 2017 by *RaCeR^ Link to comment
Mr.Loki Posted April 10, 2017 Share Posted April 10, 2017 it's an event you attach it to your browser element like how you attached the onClientClick event to the cinema button. function geturl() guiSetText(addressBar,getBrowserURL(source)) end addEventHandler("OnClientBrowserNavigate",theBrowser, geturl) This event will be called every time the browser navigates to a different page. Link to comment
*RaCeR^ Posted April 10, 2017 Author Share Posted April 10, 2017 Sorry, but i try this and not working :c, It's a simple thing that's giving me a headache. the EDIT bar not Recognize. Link to comment
Function Posted April 11, 2017 Share Posted April 11, 2017 loadBrowserURL(source,"https://www.youtube.com") Link to comment
Administrators Lpsd Posted April 11, 2017 Administrators Share Posted April 11, 2017 (edited) function geturl(targetURL) guiSetText(addressBar,getBrowserURL(targetURL)) end addEventHandler("OnClientBrowserNavigate",resourceRoot, geturl) If that doesn't work, are you getting any errors in debugscript? Edited April 11, 2017 by LopSided_ Link to comment
*RaCeR^ Posted April 11, 2017 Author Share Posted April 11, 2017 (edited) function geturl(theBrowser) -- Function of URL Link to guiSetText with a Button Command if source == CINEMA.button[1] then guiSetText(addressBar,getBrowserURL(theBrowser)) end end addEventHandler("onClientGUIClick",root,geturl) local theBrowser = guiGetBrowser(browser) -- Function of the Browser addEventHandler("onClientBrowserCreated", theBrowser, function() loadBrowserURL(source,"https://www.youtube.com") end ) Don't have any errors in debugscript and it works with the button function, if i put the function to he goesn't alone :c If anyone can help me with this file, contact me Pv. Please :c ( i send the script ) Edited April 11, 2017 by *RaCeR^ Link to comment
dk99 Posted April 11, 2017 Share Posted April 11, 2017 (edited) Please explain: "when I click the link it automatically changes the URL in the text bar?" Which link and where? Are you talking about links that are rendered within the browser or any GUI/DX text link? The code provided by LopSided_ should work absolutely fine. local theBrowser = guiGetBrowser(browser) -- Function of the Browser addEventHandler("onClientBrowserCreated", theBrowser, function() loadBrowserURL(source,"https://www.youtube.com") end ) function geturl(targetURL) guiSetText(addressBar, getBrowserURL(targetURL)) end addEventHandler("OnClientBrowserNavigate",resourceRoot, geturl) Edited April 11, 2017 by dk99 1 Link to comment
*RaCeR^ Posted April 11, 2017 Author Share Posted April 11, 2017 9 hours ago, dk99 said: Please explain: "when I click the link it automatically changes the URL in the text bar?" Which link and where? Are you talking about links that are rendered within the browser or any GUI/DX text link? Yes, the URL Changes in the text bar automatically, Yes, Every Link, and Rendered within the Browser, like Chrome example, but for the Youtube, u Click on a Video and URLText changes automatically. ( i can make a little video for explain if u want ) Link to comment
*RaCeR^ Posted April 11, 2017 Author Share Posted April 11, 2017 Here, have these errors, I think that's the problem, anyone can fix ? :C Link to comment
*RaCeR^ Posted April 12, 2017 Author Share Posted April 12, 2017 Update: http://imgur.com/a/T1KbC It works only when you put it in 1 time it goes, then it does not work anymore. type: i'm enter the youtube, but, if i click on a video, the URL don't change. function geturl(theBrowser, b) bool = true for b, v in string(b, browser) do guiSetText(addressBar, getBrowserURL(theBrowser)) end end addEventHandler("onClientBrowserNavigate",root,geturl) addEventHandler("onClientBrowserDocumentReady",root,geturl) Link to comment
Mr.Loki Posted April 13, 2017 Share Posted April 13, 2017 That was 1 of the problems I came across when I made my youtube script. The problem is youtube's site, not the script because if you try it with this forums it will work perfectly. Maybe you can check either of my youtube scripts and probably find the solutions and get some tips. Link to comment
*RaCeR^ Posted April 13, 2017 Author Share Posted April 13, 2017 Thx, i will see your script, maybe i'll use somethings and i'll put your credits s2. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now