PDA

Click to See Complete Forum and Search --> : Javascript :-(


turfbult
Jan 30th, 2001, 06:15 AM
Hello,

I have some ASP code which reads thru a table and gets info from it like name, html etc.

This info is used to build a table in HTML which displays the NAME and if there is a link to a webpage it adds the hyperlink which I get from the HTML fields in my db.

This is how I do it... (not all the code...)

html = rs("html")
response.write "<tr><td width='33%'><p><font face='Arial'size='2'><a href=" & link2 & ">" & rs("name") & "</a></font><br></td>"

link2 = "Javascript:windowOpen2()"
this is a reference to a javascript function

This function looks like this...
<script language="JavaScript">
<!--
function windowOpen2()
{ window.open('<%=html%>',"NewWindow","width=500,height=320,noresize=yes,scrollbars=no,toolbar=0,menubar=0");
}
// end popup windows -->
</script>

html in this function is the HTML field read from my db.

My problem is.... how can I change link2 to have the HTML included in it. In other words, I want to pass the field HTML to my function. So link2 must look something like

link2 = "Javascript:windowOpen2(),"<%html%>" (I've got no clue how the code should look like - just trying to demonstrate what I mean)

To explain a bit more...
There can be many "NAMES" which have webpages(HTML from my db) attached to it. I want the user to be able to click on a specific name and the corresponding webpage will open in a new window. What happens now is that all names show the SAME WEBPAGE, because right at the top (check my code) I set html = rs("html"). Thats why I need to know how to change "link2" (as example above) so that each and every NAME displayed on my page will have an unique "link2".

This was NOT easy to explain - I hope you see what I'm getting at.

Thanks,
T

sebs
Jan 30th, 2001, 07:06 AM
link2 = "Javascript:windowOpen2(),"<%=html%>"
this should work, did you try it!

or put

<a href="<%=yourHTMLPath%>">This is a link</a>

turfbult
Jan 30th, 2001, 08:01 AM
Jip, I tried it and it does not want to work!!

The reason why I want to open the new window (maybe stupid) using the javascript function is because I can then set things like noresize,scrollbars=no,toolbar=0,menubar=0 etc etc.

The main thing I want to be able to do is set the size of the window!!

Can I do this using your second example....
<a href="<%=yourHTMLPath%>">This is a link</a>

I know to open the page in a new window you set the target="blank". How do I set the size,scollbars etc??

If I can determine the size, hide scrollbars etc then I will be able to go for your second suggestion.

Thanks,
T

sebs
Jan 30th, 2001, 08:12 AM
ok do:

<a href="javascript:myFunction();">this is a link</a>

and in your function:

function myFunction(){
newWin = window.open("your page","_blank","width=350,height=150,menubar=0,location=0,toolbar=0,personalbar=0,status=0,scrollbars=0");
if (newWin.opener == null) newWin.opener = self;

but if you need more function,write it in asp:

response.write "<script languiage=javascript>"
response.write "function " & yourName
.....
response.write "</script"

do it for all so in your link:
<a href="javascript:<%=yourFirstNameFunction%>;">this is a link</a>

do you know what i am saying,i hope i did'nt lost you!

monte96
Jan 30th, 2001, 11:00 AM
Why not pass the URL to the function and make it generic?

turfbult
Jan 30th, 2001, 11:20 AM
Sounds good monte96,

Can you give me some example code please??

T