Jump to content

Something for anybody


dooberry

Recommended Posts

Can someone help me please?I'm doing stuff in xsl/xml - but that's not really important.If I have a text variable which contains a string of html, how can I use script to make a frame show the output of the text variable?I have a web page with 2 frames, one for navigation and one for display.When the user clicks a button/image on the left I want my script to build the html to display on the right.I appreciate that this is an unorthodox way of using frames, but it is important that it works this way.Any help would be appreciated :(:):):D:) .Dooberry.

Link to comment
Share on other sites

Hi dooberry, try this.Create a frameset:

<frameset cols="25%,75%">   <frame src="frame_a.htm" name="a">   <frame src="frame_b.htm" name="b"></frameset>

frame_a.htm

<head><script>var newPage1="<body><h1 style='color:red'>hello I am newpage 1</h1></body>";var newPage2="<body><h1 style='color:yellow'>hello I am newpage 2</h1></body>";</script></head><body><input type="button" value="Page 1" onclick="window.parent.frames['b'].document.body.innerHTML=newPage1;" /><input type="button" value="Page 2" onclick="window.parent.frames['b'].document.body.innerHTML=newPage2;" /></body>

frame_b.htm

<p>Frame b</p>

Link to comment
Share on other sites

Scott,Thanks for the info. I've tried this and it's raising the same error that I was getting before - 'Exception Occured' :blink: . I've tried tweaking the code to the following (bearing in mind I'm using vbscript not java):

window.parent.frames("frm").document.write xmldoc.transformnode(xsldoc)

and I'm still getting the same problem :):(:D .The only thing I can think is that the reference to the frame is not working or the transformnode function is not returning correct html?If you or anyone else can see anything wrong with my code then please reply asap. :) Any help is always welcome :) .Dooberry

Link to comment
Share on other sites

If I have a text variable which contains a string of html, how can I use script to make a frame show the output of the text variable?I have a web page with 2 frames, one for navigation and one for display.When the user clicks a button/image on the left I want my script to build the html to display on the right.
In terms of the above question the code i provided does just that, in JavaScript. (i double checked it again just now)I didnt realise you were using vbscirpt, i'm not very familiar with that :) sorry
Link to comment
Share on other sites

I'll try it in java (I'm sure if I plug away it'll work). It's as if VB doesn't reference the frames collection properly so it can't identify items within it, there's naff all help on the MSDN website about it so stuff MS.At least I don't have to use C++ to do it, now that would be difficult (or not depending on whether or not I write my own XML model - talk about reinventing the wheel)!!Thanks for your help and I'll try it your way this time.Dooberry. :):):(:blink::D:)

Link to comment
Share on other sites

Just for the protocol. I see "exeption occured" every time there's something wrong in the XSLT. Are you sure your XSLTs are ALL correct? If any of the used ones is wrong, this would crash the whole thing, so it would be pretty obvious why do you see such error.

Link to comment
Share on other sites

As far as I can tell the XSL is ok.I've linked the xml sheet to it directly and the form appears and behaves exactly as I would expect.I've also used a page with script to execute the transform using XMLDOM and it still appears ok.I've used the script debugger that ships with MS Office to look at the frame script and I've put in the code one step at a time.If I create a watch on the code doing the transform then I can see the html as a string.I can also see the innerhtml attribute of the current frame as a string via the documentelement property.If create a watch on 'window.parent.frames("frm")' then this always creates the exception - frm is the name of the frame where I want the output to appear.Up until that point it allows me to navigate the object.I think that there is one of two problems occuring - either the frames collection does not support reference to a member of the collection by name or I am not referencing the frame correctly.Either way I'll let you know if the Java fixes it.

Link to comment
Share on other sites

:blink::(:(:):D I am a cunning devil!!!! I used the object browser to find another way down to the frames collection that worked and here it is:
window.frameElement.parentElement.document.frames['frm'].document.body.innerHTML=LoadPage('quote.xml','contact.xsl')

It's ugly but it works!!And here is the code for LoadPage:

function LoadPage(xmlpage, xslpage) {	var xmldoc, xsldoc, page	xmldoc=new ActiveXObject("Microsoft.XMLDOM");	xmldoc.async="false";	xmldoc.load(xmlpage);	xsldoc=new ActiveXObject("Microsoft.XMLDOM");	xsldoc.async="false";	xsldoc.load(xslpage);	page = xmldoc.transformNode(xsldoc)	return page}

Thanks for all your help and inspiration - this is a major breakthrough in my project and I can do everything I need from here.Dooberry :):):(:D:) .

programming is like learning a foreign language because there are new words to learn and a strong grammatical structure. what matters is that you know what you want to say - Dan Cambridge (aka Dooberry)
Link to comment
Share on other sites

:D  :) Ok, this works fine for loading in the form but now the script that is in the xsl file doesn't work :)  :) .How do I get round that? :(  Dooberry

What happens instead? The script is displayed as plain text? Where is it from? Another file? In the XSLT file directly? Aanother file imported with the src attribute in the XSLT? Else?
Link to comment
Share on other sites

It's most peculiar, but I think it's because I'm setting the innerHTML property.What happens is the form displays where it should and as it should, but there is script which should run in the form.When the event happens that should trigger the script, the page generates an error which says "submitrecord not defined" (submitrecord is the name of the procedure that stores the record).I think I have to use the write() method of the document object to get this to work, I'll let you know if this fixes it :).Dooberry

Link to comment
Share on other sites

Right,I got the script to work by replacing the code with the following:

window.frameElement.parentElement.document.frames['frm'].document.write(loadpage('<xmldocument>','<xslsheet>'))

this is quite funny, does anyone know the song "there's a hole in my bucket"?What's happened is I created a .hta file to do the transform so that I would gain access to save the output document when I first created the form - sorted.Then I had the palava with putting external document references in to create select controls - sorted.Then I wanted a menu of links to navigate the different portions of the document and make entry easier - sorted.Now I'm back at step 1 and I've lost the permission to use the XMLDOC.save method again even though I have an hta file running and executing the code.Does anyone know a way to override the local permissions of the page to allow saving of an xml document?

Link to comment
Share on other sites

Ok, I've had a re-think about this and although it works, the problem is that the code which writes to the xml file is not direct content of the hta page - this means that frames are not viable.Is there a way of emulating frames with a table (probably not considered good technique)?What I am considering is that I have a table with the navigation items at the top and the form underneath (I assume that there will be some way of using thead and tbody to do this?).Has anyone used this before and is there a clever way of doing it?The essence of it will be whether or a <td> element has a document property.If anyone can answer this can you please help?Thanks folks.Dooberry

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...