|
Set the width of the DIV block to a fixed value and make its position absolute so you can work with it under IE and Netscape.Create it as invisible. The browser should then set its height to a value so that the block will accomodate its contents. Now you can retreive this value with:
IE: document.all["strID"].offsetHeight
Netscape: document.layers["strID"].clip.height
This way you have the dimensions of the block (you know the width because you fixed it at the beginning) and you can center it in the browser window. Don't forget to make the block visible!
Bye
|
|
|
|
|
OK, thanks - I'll try that. At the moment I can't even get code to work consistently between IE4 and IE5 - don't you just love the concept of backwards compatibility? Microsoft have clearly never heard of it.
|
|
|
|
|
Sorry, this is slightly lengthy to give all possible information.
I'm having difficulty retrieving the width and height (or anything, for that matter) from a block defined with a DIV. I predefined its position and size using the standard stylesheet approach, so it DEFINITELY has a position and size (and I can see it occupy those dimensions, so I know it works).
I am trying to get the size like this:
function GetDIVObject(strID)
{
var Object = null ;
switch (g_iBrowser) // Assume this is correctly set.
{
case BROWSER_IE :
Object = document.all[strID].style ;
break ;
... and other cases for other browsers, I'm using IE5...
}
}
var Object ;
Object = GetDIVObject("CategorySelect") // This name is OK
// The object returned is not null, as the browser is
// correctly recognised as IE.
I have tried:
iWidth = Object.width
iWidth = Object.posWidth
iWidth = Object.pixelWidth
but none of them return anything useful - the first returns blank or undefined, the others return 0.
The DIV block is defined not directly into an HTML page but
by document.writeln() statements creating the HTML lines - but this MUST work because I do see the created DIV (it contains a combo box). The call to get the size IS located AFTER the declaration of the DIV.
I am trying to do this so that I can centre the DIV in the available client space.
Any ideas?
|
|
|
|
|
I think the problem is in the function GetDIVObject(strID). Try the following:
return document.all[strID].style;
instead of:
Object = document.all[strID].style;
because you're assigning the return value of the function to Object.
|
|
|
|
|
Thanks, but this is not the problem. There is absolutely no difference between
---
Object = document.all[strID].style ;
return Object ;
---
and
---
return document.all[strID].style ;
---
It is a standard C / C++ way of preparing a return value, even for an object (or object pointer).
I managed to get it working by starting from scratch, although I haven't found out what was wrong with it the first time yet.
|
|
|
|
|
If you look at the code in your 1st message you will see that you didn't do a
return Object;
and that's why I told you to try with
return document.all[strID].style;
perhaps you did it in the original code but forgot to write it in your 1st message. If you still want to know what the problem was, I could try to find it if you send me all the code to
haykel@cs.tu-berlin.de
Bye
|
|
|
|
|
Oops, I see you're right and I missed it from the sample code. So much for "giving all possible information" {:v( I DID, however, have it in the actual code.
I appreciate the offer of help, but let me try to find the problem first - it's the best way to learn. If I can't find it, I'll come back to you.
Thanks.
|
|
|
|
|
I need a function (in ASP) that will go through an RTF string and return plain text or HTML. Or even string manipulation suggestions. Thanks
|
|
|
|
|
Hi all,
I'm wondering if there is a simple way to allow a single form to have two "actions". ie. the form is declared as:
...
When the submit button is pressed, all data is sent to MyPage.asp. What I'd like to do is have another "submit" button that sends all data to MyPage2.asp (for example). Effectively I'd like to have a form that allows the user to choose which page the form's data is sent to.
|
|
|
|
|
You can't send to multiple pages. What I do is to evaluate the pressed button in the receiving form "MyPage.asp" and then branch accordingly.
if button 1 is pressed then
xxxxx
else
yyyyy
end if
With IIS 5.0, there is a Transfer()-method to let the server do this. In IIS 4.0 there is no such method. One could work-around with #include statements.
|
|
|
|
|
Hmm. I was hoping there was a possible javascript solution. Oh well
|
|
|
|
|
Hi Chris!
You can put one or more buttons on the form and then process their OnClick events, specifying the form's action and submitting the data. See example below...
Regards,
Alex Gorev,
Dundas Software.
********************************************************
function OnUpload() {
document.form1.action = "test2.asp"
document.form1.submit();
}
|
|
|
|
|
This did the trick - except that in IE5 I got an error stating that the document.form1.submit(); method was not a member of document.form1 - so I left it out and it worked fine.
Setting document.form1.target = "page2.asp" answered my second question (that I'd not actually posted) about having the form open the page in a separate window.
Gotta love javascript...
|
|
|
|
|
I don't think it will work on a Netscape client... very few tags support the OnClick etc events in Netscape.
|
|
|
|
|
Oops - I'm wrong! )
|
|
|
|
|
Background:
The project I'm starting on is a web-based questionnaire. Users will go page to page filling in data. The number of pages is not fixed (it will vary according to user data). The site will be database driven (questions and the pages that contain them will be organized in a server database).
Question:
Marketing (ahem) has required us to be able to print all of the pages for the user - on the user's system. Ie., the user presses "print" and he gets hard copies of all of the pages that he could visit, not just those he has already visited, on the site.
I am stumped. I am pretty sure that pressing Print on any browser will print the current page, and the current page only. Telling users to press print, next page, print, next page, etc. is out of the question.
One option is to render the pages on the server to a PDF file using the Acrobat printer driver (can you append to a PDF this way???), then email the PDF back to the user. This is lame, too.
Printing hard copies and snail mailing them back to the user is another (bad) option.
Pre-rendering the pages to PDF is out of the question as the number and content of the pages will vary from user to user.
This seems like a problem that people would be constantly running into... has anyone solved it?
|
|
|
|
|
What about just recreating all the pages that should be printed in ONE SINGLE page with a CGI or ASP script and tell the user to print that page. This will also give the user an idea about the amount of data that will be printed, so he can decide if he wants to do so or not.
|
|
|
|
|
we want to preserve some kind of structure in the printed version, since these documents will likely be 20-30 pages. but, there's no way to force a page break when printing a web page.
|
|
|
|
|
|
Well _I_ would do the following:
When the user presses PRINT, I would generate a new page, with all the information in printable form (no images, just core information, all pages on ONE page, etc.).
Then the user must be advised to press the print button in his browser on THIS page.
On IE, you can even print automatically with javascript, if the page is loaded.
|
|
|
|
|
In ASP if i use Server.CreateObject(ANYCOMOBJECT)
I get the deafult interface pointer defined in the IDL file of that COM object. Now how to call the method of other interface which is there in my COM object.
|
|
|
|
|
When using Server.CreateObject() you have to provide a ProgID as a parameter. To the best of my knowledge ProgID is unique for each interface (correct me if I am wrong), so you should never have this problem. Also I could not find any references in documentation on being able to create object using default interface.
|
|
|
|
|
Hi!
VBScript/JScript access your object using the IDispatch interface and you cannot implement two IDispatch interfaces on a single object and make both available to Active Server Pages (ASP) clients.
What you can do instead, is to add a method (property) to the default interface which will return a pointer to the other IDispatch derived interface.
Regards,
Alex Gorev,
Dundas Software.
|
|
|
|
|
I am trying to run an external program using IIS and ASP on a Win 2K machine. This program is just a dops based program that has to be run on the server.
I have tried the AspExec component from serverobjects.com: http://www.serverobjects.com/products.htm#free
However I have not had any success getting it to work. Does anyone have any thoughts on what to try next??
Cory
|
|
|
|
|
This is a bit simplified, but basically you can write a little ATL DLL that calls CreateProcess. Leave the application name null and specify something like "cmd myprog.exe" in the command line parameter.
There are lots of subtleties in store depending on what you need from your program (stdin/out pipes are tricky) but this sort of thing works on NT and w2k - win9x too, but not as nicely. cmd has some useful switches you might want to check as well.
Tim
|
|
|
|