Error of embed php webpage(like http://forums.cgsociety.org)


#1

Hi,
I have a project using web page via maxscript,for quick searched ,this code can do that but cause error


( 
wb = dotNetObject "system.windows.forms.webbrowser" pos:[0,0] 
wb.url = dotNetObject "System.Uri" "http://forums.cgsociety.org" 
--wb.url = dotNetObject "System.Uri" "http://localhost/wordpress/wp-login.php" 
webForm = dotNetObject "System.Windows.Forms.Form" 
wb.bounds=dotNetObject "system.drawing.rectangle" 0 0 1920 700 
webForm.controls.add wb webForm.topmost = true webForm.Width=1920 
webForm.Height=700 webForm.show() 
)

it seems maxscript loads web page via IE,the js script seems not running correctly,my system is win7 64 bit,as you can see the attachment, if the url is home page of cgsociety,the text does not display corroctly,also I cannot login via this way,if the url is wordpress site,some plugin if use js,the browser in maxscript always display errors ,any body know how to fix that?


#2

you can disable js errors

wb.ScriptErrorsSuppressed = true

#3

Thanks for help,if worked,no messagebox display again,but the js function does not work either,just like I still can not login in the cgsociety via this way,is that can fix?


#4

I think the wb object is running like Internet Explorer 8 or something, it’s an ancient browser, probably very insecure and I don’t think it will run most websites correctly. There must be a way to put a more modern browser in using dotNet… anyone?


#5

I agreed,if maxscript can assign a modern browser, like firefox,oprea etc,I think this issue will be fixed,but,HOW?


#6

/*
-- Logout by clearing session cookies
fn clearCookies = (
	
	wb.Navigate "javascript:void((function(){var a,b,c,e,f;f=0;a=document.cookie.split('; ');for(e=0;e<a.length&&a[e];e++){f++;for(b='.'+location.host;b;b=b.replace(/^(?:%5C.|[^%5C.]+)/,'')){for(c=location.pathname;c;c=c.replace(/.$/,'')){document.cookie=(a[e]+'; domain='+b+'; path='+c+'; expires='+new Date((new Date()).getTime()-1e11).toGMTString());}}}})())"
	wb.Navigate "http://forums.cgsociety.org"
	dotnet.removeeventhandler wb "DocumentCompleted" clearCookies
	
)

dotnet.addeventhandler wb "DocumentCompleted" clearCookies
*/

fn cgsocietyLogin = (
	
	local login = "Serejah"
	local pass = "*********"
	
	local str = "javascript:function foo(){loadLogin();document.getElementById('username').value = '"
			str += login
			str += "';document.getElementById('password').value = '"
			str += pass
			str += "';document.forms[0].submit();}foo();"
	
	wb.Navigate str
	dotnet.removeeventhandler wb "DocumentCompleted" cgsocietyLogin
	
)

dotnet.addeventhandler wb "DocumentCompleted" cgsocietyLogin

works for me


#7

Thanks for your code,it seems does not work for me,please see attachment,
My project need to embed wordpress site,does this cookie function works too?
I just want the embed browser via maxscript works as a normal browser,it seems too difficult to do that…


#8

i’m not sure whether those functions will work as expected in case of wordpress.
to logout you can use wordpress logout url instead

wb.navigate "[wordpress_logout_url](http://codex.wordpress.org/Function_Reference/wp_logout_url)"

there’s plenty of third party browsers for .net webbrowser replacement.


#9

Thanks for greate help,Serejah,you point me a good direction
:bowdown:


#10

By default, the webbrowser control uses a rather low version. But you can tell your application to use a higher IE version by setting a registry version. Since we’re using the webbrowser control within 3dsMax we need to set a registry value for 3dsMax.

function fn_regeditIE browseremulationValue =
(
	/*<FUNCTION>
	Description
		sets a key in the registry which enforces a specific version of IE when run in 3dsMax
		This key is only in use after a full restart of 3dsMax, bummer
	Arguments
		<int> browseremulationValue: a value to set in the registry
	Return
	<FUNCTION>*/
	
	--9999 gives bad redirect url
	--10999 gives issues on win10
	--10000 seems to work
	
	--Set a registry key in order to use a modern IE version. This key kicks in after 3dsMax has been restarted, bummer
        local keyPath = @"SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION"
	registry.createKey HKEY_CURRENT_USER keyPath accessRights:#all key:&subKey
	registry.setValue subKey "3dsmax.exe" #REG_DWORD browseremulationValue 
	registry.flushKey subKey
	registry.closeKey subKey
)

If you use this script for yourself, then you’re ok. Just set the registry value to something that works for you, restart 3dsMax and you’re good to go. If you plan on distributing your script, get ready for a world of hurt. Some people actually only have IE 8, or are on windows 10 or have some other browser compatibility issue. And beyond that, users might have uninstalled IE altogether. You’ll have a lot of scenarios to test to say the least.
Using a 3rd party browser control might help but they tend to be pretty big libraries. Again, if you’re the only user that’s fine, but if you plan to distribute the script to other users that might be an issue. Maybe Serejah can recommend one of the browser controls he’s linking to.


#11

Hi Klaas,
Thanks for the code,I will try it later,I totally agree,I am not the only user,yesterday I test a way from Serejah recommend to fix that,just place
<meta http-equiv=“X-UA-Compatible” content=“IE=edge,chrome=1” />
to wordpress head.php,then IE can be forced to using a higher version,it works,but like you said,some people has another browser,it will cause issues.
With your suggestion,I am going to find a 3rd party browser,it might be a best solution.
There still 1 major problem to be solved for me,I want to access temporary internet files,like images,I don’t know how to do that by 3rd praty browser,I need spend several days to find a solution,whatever,too much thanks for everyone’s help!!