roco Topic Starter
Posts: 21
|
 |
« on: January 09, 2012, 12:20:04 PM » |
|
Hello all, I am searching for a code that will open,a new URL in a new window when anywhere on my index page is clicked.I have my own website,but want to promote a new website venture,and have come across thousands of codes.Problem is with those codes is that my members have to push a link to access that new URL.I just want them to click anywhere on that index page to "trigger" that new window.I don't want to annoy my customer so will there also be a way to have that new URL "trigger" one time per visit,or per day?I have looked and looked,and have been close but no cigar just yet.You guys have been heaven sent to me in the past,so i thought I would stop be and ask..Thanks Everyone,and I hope everyone is having a great New Year!!
Roco
|
|
|
|
|
kpac Web moderator Moderator
Thanked: 180 Posts: 5,874
Certifications: List Computer: Specs Experience: Expert OS: Windows 7
kpac®
|
 |
« Reply #1 on: January 09, 2012, 12:39:41 PM » |
|
This isn't as easy as you might think, but this should work.
CSS
*, html, body { width: 100%; height: 100%; } a.fullscreen { display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 9999; }
First, the HTML document's height and width have to be set to 100%. Then we create the properties for the <a> that will hold the link you want people to click on.
HTML is simple enough...
<a href="wherever" class="fullscreen" target="_blank"> </a>
This has to be put either at the very top after <body> or at the very end before </body>.
If you want to hide the link when someone clicks on it, javascript will be needed.
|
|
|
|
« Last Edit: January 09, 2012, 01:21:54 PM by kpac »
|
IP logged
|
|
|
|
roco Topic Starter
Posts: 21
|
 |
« Reply #2 on: January 09, 2012, 12:49:02 PM » |
|
Hey kpac!! Hows it going? Thanks for this code sir I will give it a go. And yes I wanted to hide the link,and instead have my members click anywhere on the page to trigger the URL.
|
|
|
|
|
|
|
roco Topic Starter
Posts: 21
|
 |
« Reply #4 on: January 09, 2012, 01:19:50 PM » |
|
Ok so where exactly should I place the first code?
*, html, body { width: 100%; height: 100%; } a.fullscreen { display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 9999; } I just tried to put in the Head section but no luck. Also should I place <a> *[/url] at the beginning and end of this code? Pretty sure the answer is yes just checking lol.
|
|
|
|
|
|
|
lina19
Posts: 36
Experience: Beginner OS: Unknown
|
 |
« Reply #6 on: January 09, 2012, 02:26:07 PM » |
|
i dont know if u exactly ask this: try it and see:
<html>
<script type="text/javascript"> function click_on() {
window.location="a.html";
} </script>
<body onclick="click_on()">
</body> </html>
|
|
|
|
|
|
|
lina19
Posts: 36
Experience: Beginner OS: Unknown
|
 |
« Reply #8 on: January 09, 2012, 02:57:50 PM » |
|
hehe....
|
|
|
|
|
roco Topic Starter
Posts: 21
|
 |
« Reply #9 on: January 09, 2012, 03:28:38 PM » |
|
Ok which one should I use here  Kpac when I use yours I can see that actual coding on my index page,so should I start it with <html>? And thank you lina19 for your code,but where should I insert my new url,and will this open in a new window? Thanks to both of you!!
|
|
|
|
|
|
|
roco Topic Starter
Posts: 21
|
 |
« Reply #11 on: January 09, 2012, 03:49:04 PM » |
|
Thank you!! We are definitely on the right path here!! Only two more questions..(You have helped me so much here I feel bad for asking) but when the new URL opens it opens in a new tab,is there a way to have it open in a completely new window? And my second question is there way to only have this window open for new visitors or like once per day per IP address? Currently it is opening in a new tab every time the page is clicked lol. I Hope I am not asking for too much from you two. If I am I understand and very greatfull for what you provided.
|
|
|
|
|
lina19
Posts: 36
Experience: Beginner OS: Unknown
|
 |
« Reply #12 on: January 09, 2012, 03:55:20 PM » |
|
its ok...i dont mind...but im not understanding your question clearly...
u mean its opening in another tag??
window.location is supposed to open you to another window....change the filename....try to test it with a fresh page and see...
i havent understood your second ques..
cordialy, .....
|
|
|
|
|
lina19
Posts: 36
Experience: Beginner OS: Unknown
|
 |
« Reply #13 on: January 09, 2012, 04:01:42 PM » |
|
sry...i read it again....i did understand...what u mean...wait i will reply in some minutes
|
|
|
|
|
roco Topic Starter
Posts: 21
|
 |
« Reply #14 on: January 09, 2012, 04:07:51 PM » |
|
ok thanks!!
|
|
|
|
|
lina19
Posts: 36
Experience: Beginner OS: Unknown
|
 |
« Reply #15 on: January 09, 2012, 04:48:56 PM » |
|
or u working with only javascript??you cant do the "ip" part with javascript+ database...
u will need to add all your ips in a database/textfile by using php(server side)... whenever a new person comes...validate this new ip with your exisiting database value.. if it is not seen in the database, open page
in php u have a function known as header( instead of window.location...something like this i forgot exactly....
else u can do this in javascript,
var [] array_list="<?php echo $array_list ?>";
var new_ip="<?php echo $newip ?>";
for (int i=0;i<array_list.length; i++) {
|
|
|
|
|
lina19
Posts: 36
Experience: Beginner OS: Unknown
|
 |
« Reply #16 on: January 09, 2012, 04:52:50 PM » |
|
for (int i=0;i<array_list.length; i++) { if (array_list.equals(new_ip)) { window.location="a.html"; } }
sry...i havent worked with php nor javascript for one year...i have forgotten about the syntax...but the logic is here....and i guess u can understand it as ur a programmer as well....
u can use ajax as well to do it....
u cant extract ip from javascript....its impossible...
u can use java like applets to extract ip as well...
|
|
|
|
|
roco Topic Starter
Posts: 21
|
 |
« Reply #17 on: January 09, 2012, 05:25:56 PM » |
|
That is quite ok..You have helped me a great deal!! I wish I was a programmer lol,but I am learning as I go along. Thanks again for your help!!
|
|
|
|
|
kpac Web moderator Moderator
Thanked: 180 Posts: 5,874
Certifications: List Computer: Specs Experience: Expert OS: Windows 7
kpac®
|
 |
« Reply #18 on: January 10, 2012, 12:01:20 PM » |
|
Lina, please use the CODE tag when displaying code in your posts... // like this
window.location = "URL HERE";
This just sends the user to a new URL in the same window they are currently looking at. window.open("URL HERE", "_blank", "width=300,height=200");
This opens a new window/tab with the specified URL. You can change the width and height if desired (in pixels). Whether a new tab or window opens depends on the browser. I think IE opens new windows, Firefox opens tabs etc....there's no way to specify which one you want (I'm 90% sure). To only display it once a day for each visitor is more complicated and involves using cookies to check the last time they visited the site. See Google.
|
|
|
|
lina19
Posts: 36
Experience: Beginner OS: Unknown
|
 |
« Reply #19 on: January 10, 2012, 12:10:56 PM » |
|
thx kpac...but where is the "code tag"...im not finding anything to help me show my codes...thanks beforehand
|
|
|
|
|
|
|
lina19
Posts: 36
Experience: Beginner OS: Unknown
|
 |
« Reply #21 on: January 10, 2012, 12:27:58 PM » |
|
test
|
|
|
|
|
lina19
Posts: 36
Experience: Beginner OS: Unknown
|
 |
« Reply #22 on: January 10, 2012, 12:28:24 PM » |
|
ok thx
|
|
|
|
|