mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 01:44:06 -04:00
infusing "<script language="javascript"></script>" tag if such was not specified on the page
This commit is contained in:
parent
b242318279
commit
b83063a53b
@ -308,6 +308,46 @@ int CP3DActiveXCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
||||
|
||||
::SysFreeString( url );
|
||||
|
||||
CComPtr<IHTMLElementCollection> pHtmlElementCollect;
|
||||
hr = pHtml2Doc->get_scripts( &pHtmlElementCollect );
|
||||
if ( FAILED( hr ) || !pHtmlElementCollect )
|
||||
{
|
||||
return ( error = -1 );
|
||||
}
|
||||
long collectionLength = 0;
|
||||
hr = pHtmlElementCollect->get_length( &collectionLength );
|
||||
if ( FAILED( hr ) || !pHtmlElementCollect )
|
||||
{
|
||||
return ( error = -1 );
|
||||
}
|
||||
if ( collectionLength < 1 )
|
||||
{
|
||||
// javascript engine was not specified on the page.
|
||||
// hence we need to initialize it by infusing javascript
|
||||
// element tags
|
||||
|
||||
CComPtr<IHTMLElement> spHtmlElement;
|
||||
hr = pHtml2Doc->createElement( CComBSTR( "script" ), &spHtmlElement );
|
||||
if ( SUCCEEDED( hr ) && spHtmlElement )
|
||||
{
|
||||
hr = spHtmlElement->put_language( CComBSTR( "javascript" ) );
|
||||
if ( SUCCEEDED( hr ) )
|
||||
{
|
||||
CComPtr<IHTMLDOMNode> spElementDomNode;
|
||||
hr = spHtmlElement->QueryInterface( IID_IHTMLDOMNode, ( void** )&spElementDomNode );
|
||||
if ( SUCCEEDED( hr ) && spElementDomNode )
|
||||
{
|
||||
CComPtr<IHTMLDOMNode> spHtmlDomNode;
|
||||
hr = pHtml2Doc->QueryInterface( IID_IHTMLDOMNode, ( void** )&spHtmlDomNode );
|
||||
if ( SUCCEEDED( hr ) && spHtmlDomNode )
|
||||
{
|
||||
CComPtr<IHTMLDOMNode> newNode;
|
||||
hr = spHtmlDomNode->appendChild( spElementDomNode, &newNode );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
std::string p3dDllFilename;
|
||||
error = m_instance.DownloadP3DComponents( p3dDllFilename );
|
||||
if ( !error && !( p3dDllFilename.empty() ) )
|
||||
|
Loading…
x
Reference in New Issue
Block a user