Solved

createpopup() questions

Posted on 2004-09-22
6
1,059 Views
Last Modified: 2008-01-09
I have two questions:
1. Can you hide the scrollbar when using the createpopup method?
var oPopup = window.createPopup();
var objDocument = oPopup.document;
objDocument.open();
objDocument.write(HTML);
objDocument.close();
oPopup.show(l,t,186,166,document.body);
No matter what I do the scrollbar always appears on the popup. The height of some of the HTML is set to 100% could that be the cause?

2. The HTML above contains a link to some javascript <script language="javascript" src="myJSfile.js"></script> but it does not appear to load this javascript because I get an object not found when calling when one of the methods within myJSfile.js. Can the popup window load javascript dynamically or does the javascript have to be typed out within the page?  I have verified that typing the javascript out in the HTML variable does work.

Thanks in advance for your help.
0
Comment
Question by:dswisstack
  • 3
  • 3
6 Comments
 
LVL 36

Expert Comment

by:Zyloch
Comment Utility
Hi dswisstack,

1) If you must use an IE-only createPopup() function, your code will show a scrollbar because of the way you're calling it.

Do this:

var oPopup = window.createPopup();
var objDocument = oPopup.document.body;
objDocument.style.border = "1px solid black";
objDocument.innerHTML = HTML;
objPopup.show(l,t,186,166,document.body);

Since you're using createPopup(), the innerHTML shouldn't matter anyways.


Apparently, though, as I was reading your question, I noticed that you can't use innerHTML because you're including a whole document. As per say, you can set your body style to overflow:hidden; or even overflow-y:hidden since this is going to be IE only. However, the default overflow:auto; should work AS long as your document doesn't exceed the window.

Note, that you can set the window height here:

objPopup.show(l,t,186,166,document.body);

Just change 166 to something higher since including a document always adds one line of space at the top and the bottom.


2) Try my suggestions above first and we'll see...

Regards,
Zyloch
0
 

Author Comment

by:dswisstack
Comment Utility
overflow:hidden worked great and answers question #1

But I still cannot get #2 to work any ideas there?

Here is some more info:
I have a link to a stylesheet in the HTML as well and it loads the stylesheet just fine.
<LINK href="my.css" type="text/css" rel="stylesheet">

but the next line does not appear to load...
<script language="javascript" src="myJS.js"></script>

When I cut the contents of myJS.js and include it in the HTML it works.


Thanks Zyloch!
0
 
LVL 36

Expert Comment

by:Zyloch
Comment Utility
That's odd. What is in your JS if you can show me...
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:dswisstack
Comment Utility
It's really nothing out of the ordinary....

Within the <body> of the HTML on the last line I have this...
<script language='javascript'>RegisterMiniCalendar('MiniCalendar1', '09222004', 'MiniCalendar1DayCell09222004', true, 'doNothing', 'HandleDateSelected')</script>

The function RegisterMiniCalendar is in a script that is included in the HTML's <head> element as...
<script language="javascript" src="/Javascript/MiniCalendar.js"></script>
SRC is a fully qualified path the the file. I have validated that the SRC is correct by calling another JS file in the same location that is an ASPX page (JS.aspx) and setting a break point (the break point gets hit).

If I take the function out of the include and just put it within a <script> block in the HTML variable it finds it and everything works great. But I'd prefer not to do it this way.

0
 
LVL 36

Accepted Solution

by:
Zyloch earned 125 total points
Comment Utility
We can try it the Microsoft way (since this is IE only anyways)

On your main page have this:

<download id="pop1" style="behavior:url(#default#download);" />

Then in your <script> tag have a function like this:

function oDone(src) {
   oPopup.document.write(src);
}

Call it when you need to with this:

pop1.startDownload("youHtmlFile.html",onDone);      

This may be better in that you don't have to store the contents in a HTML variable.
0
 

Author Comment

by:dswisstack
Comment Utility
It appears that the includes have not loaded by the time that the RegisterMiniCalendar function is called. Therefore it does not exist. I wrapped the RegisterMiniCalendar call within a method and call it on the window's onload event and the problem is solved.

Thanks again for your help Zyloch!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now