...

View Full Version : How to open text using a div?



Verity
01-12-2004, 02:00 AM
Hi again,

First I'll show you the css part my code:

<style type="text/css">
<!--
body {
margin:50px 0px; padding:0px;
text-align:center;
}
.Content {
width:675px;
margin:0px auto;
text-align:left;
padding:15px;
border:1px dashed #333;
background-color:#eee;
}
.ContentB {
width:auto;
margin:10px;
border:1px dashed #333;
}
-->
</style>

I have a div that calls the class "content". What I would like, and what I don't know if it is possible or not, is if I could open the same info that is in the div with the class "content", in another window containing a div with the class "contentB", by way of clicking a link or button.

Sorry for not explaining things well. I will try and answer all questions to the best of my ability.

Thanks for any and or all help that I receive.

freak
01-12-2004, 05:00 AM
You can't do that directly with CSS. You'd have to use either Javascript or a combination of Javascript and PHP to achieve that.

// freak

mindlessLemming
01-12-2004, 06:56 AM
First off, change your CSS -


#Content {
...
}
#Content b {
...
}

Now assign the divs id's of "Content" and "content b" instead of classes.
This is because these elements are unique within the page; ie, there is only one of each.

the javascript you would use if they were both on the same page would be something along the lines of

getElementByID(content).innerHTML = getElementByID(content b).innerHTML

NOTE: I don't claim to know JS, and the above script won't work. I've provided it as an hint in the right direction.

Mhtml
01-12-2004, 01:52 PM
Yeah, you're supposed to have quotes in there ;) ..

This is a js question so I'll move it to the correct forum and I'm sure someone will be along to help you.

Verity
01-13-2004, 03:02 AM
Thanks for all of the replies.

Using Javascript would be fine, but I know nothing about it or at least very little.

So I can use all the help I can get. I really do appreciate it.

Thanks again

glenngv
01-13-2004, 05:21 AM
page 1:


<html>
<head>
<style type="text/css">
body {
margin:50px 0px; padding:0px;
text-align:center;
}
#Content {
width:675px;
margin:0px auto;
text-align:left;
padding:15px;
border:1px dashed #333;
background-color:#eee;
}
</style>
<script type="text/javascript">
function doOpen(){
var w = window.open("page2.htm","content2");
w.focus();
}
</script>
</head>
<body>
<form>
<div id="Content">
I have a div that calls the class "content".
What I would like, and what I don't know if it is possible or not,
is if I could open the same info that is in the div with the class "content",
in another window containing a div with the class "contentB", by way of clicking a link or button.
</div>
<input type="button" value="Open" onclick="doOpen()">
</form>
</body>
</html>

page2.htm:


<html>
<head>
<style type="text/css">
#ContentB {
width:auto;
margin:10px;
border:1px dashed #333;
}
</style>
<script type="text/javascript">
function getContent(){
if (window.opener && !window.opener.closed)
document.getElementById('ContentB').innerHTML=window.opener.document.getElementById('Content').inner HTML;
}
</script>
</head>
<body onload="getContent()">
<div id="ContentB"></div>
</body>
</html>

Verity
01-14-2004, 01:48 AM
Oh my gosh,

A million thanks to glenngv. That is absolutely perfect. Thank you sooooo much.

Verity

Verity
01-14-2004, 02:29 AM
I have one question. What was given works absolutely perfect! I couldn't have asked for anything better. However, will that only work with an HTML page?

Can I use that same coding but open a .pl page?

Would I have to change this bit:


document.getElementById('ContentB').innerHTML=window.opener.document.getElementById('Content').inner HTML;

So I guess I need to know what part I would need to change so that I could open a .pl page in this same manner.

Thanks so much,
Verity

glenngv
01-14-2004, 02:46 AM
What do you exactly mean?
If you would like to open a perl page (or any server-side language for that matter), then you can just call it in a link or button instead of calling page2.htm.

<script type="text/javascript">
function doOpen(){
var w = window.open("page.pl","content2");
w.focus();
}
</script>
...
<input type="button" value="Open" onclick="doOpen()">

Verity
01-14-2004, 01:58 PM
Hmm, what you gave me works perfectly as I said before. I tested it using HTML and got the desired result. Then I tried it, so it would open a .pl page and the div didn't resize in the new window.

Perhaps I missed something, I'll keep at it though.

Verity
01-14-2004, 02:13 PM
Oh I see what I don't know how to do. How to add the information contained in page2.htm to .pl code?

glenngv
01-15-2004, 01:46 AM
Can you describe your problem again. I was lost when that .pl page came into the picture.

Kor
01-15-2004, 11:05 AM
How to add the information contained in page2.htm to .pl code


Submit it with a form's element.

Verity
01-15-2004, 03:16 PM
Originally posted by glenngv
Can you describe your problem again. I was lost when that .pl page came into the picture.

What you gave me works fine with html. I know html way better than I do Javascript or Perl/cgi. However, I applied your coding to my situation. But it wasn't working properly. Then I realized that, this is because I was missing the page2.htm code. To my understanding the page2.htm code should be the page that opens in the new window and thus probably be included somewhere in my .pl code.

So the page that I want to open, in my circumstance is a .pl page. I don't know how to add the code in page2.htm to the .pl page coding.

I swear sometimes I just have to pick the most difficult things to do. LOL :)

Verity
01-15-2004, 03:19 PM
Originally posted by Kor
Submit it with a form's element.

I hate to sound so dumb when it comes to these things, because I do really know things about designing. However, I know nothing about what you have replied here.

My knowledge of Javascript and Perl/cgi is non existant to say the least.

Verity
01-17-2004, 04:40 AM
Did I loose my helpers? :( :o

I had a thought, though. Is is possible to incorporate these two pages of coding into one?

Verity
01-19-2004, 12:27 AM
Anybody?? :(

Paul Jr
01-19-2004, 01:20 AM
Originally posted by Verity
Is is possible to incorporate these two pages of coding into one?
Like so?

glenngv
01-19-2004, 04:55 AM
Originally posted by Verity
So the page that I want to open, in my circumstance is a .pl page. I don't know how to add the code in page2.htm to the .pl page coding.


Originally posted by glenngv
What do you exactly mean?
If you would like to open a perl page (or any server-side language for that matter), then you can just call it in a link or button instead of calling page2.htm.

<script type="text/javascript">
function doOpen(){
var w = window.open("page.pl","content2");
w.focus();
}
</script>
...
<input type="button" value="Open" onclick="doOpen()">



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum