The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

HTML problem

2 posters

Go down

Solved HTML problem

Post by cheap jeep June 2nd 2009, 6:51 pm

I just wanted to add a little random function to my forum.
There should be a lot of differt possibilities, but my code don't work.
But it works in a normal browser, but not as a portal widget... Sad
Anyway, here is the code:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<html>
<head>
<script type="text/javascript" language="JavaScript">
<!--

var Anzahl = 7;    // Anzahl der Bilder

var ZufallJetzt = new Date()
var ZufallsZahl = ZufallJetzt.getSeconds() % (Anzahl);

// Zuweisungen abhängig von der Zufallszahl

if (ZufallsZahl==0) {
TextFarbe = "#C04000";
GrafikUrl = "http://g.imagehost.org/0410/get_aspx.jpg";
UnterTitel="Natural Boost"
Link = "http://www.google.de"
}

if (ZufallsZahl==1) {
TextFarbe="#00BF00";
GrafikUrl = "http://g.imagehost.org/0145/get_aspx.jpg";
UnterTitel="Alpine > Dream"
Link = "http://www.google.de"
}

if (ZufallsZahl==2) {
TextFarbe="#00A050";
GrafikUrl = "http://g.imagehost.org/0515/get_aspx.jpg";
UnterTitel="Rolling Hills"
Link = "http://www.google.de"
}

if (ZufallsZahl==3) {
TextFarbe="#DF0000";
GrafikUrl = "http://g.imagehost.org/0991/get_aspx.jpg";
UnterTitel="Burn the Rubber"
Link = "http://www.google.de"
}

if (ZufallsZahl==4) {
TextFarbe="#9000E0";
GrafikUrl = "http://g.imagehost.org/0627/get_aspx.jpg";
UnterTitel="StaMetrical"
Link = "http://www.google.de"
}

if (ZufallsZahl==5) {
TextFarbe="#9000E0";
GrafikUrl = "http://g.imagehost.org/0394/get_aspx.jpg";
UnterTitel="[FS] NoBoost"
Link = "http://www.google.de"
}

if (ZufallsZahl==6) {
TextFarbe="#0070C0";
GrafikUrl = "http://g.imagehost.org/0679/get_aspx.jpg";
UnterTitel="Dead Island!"
Link = "http://www.google.de"
}


function Zufallsbild01() {
document.write("<a href=" + Link + "><img src='" + GrafikUrl+ "' width='320' height='240' border='1' alt='Texxxt'></a><br>")
document.write("<font color='" + TextFarbe +"'>" + UnterTitel + "</font><br>")
return
}

// -->
</script>
</head>


<body>

<div align="center">

<script type="text/javascript" language="JavaScript">
<!--
Zufallsbild01();
//-->
</script>

</div>


<br><br>
</body>
</html>

Pls help me!

BTW: It should display a picture with a link to google and a little text below.

groar
avatar
cheap jeep
Forumember

Posts : 28
Reputation : 0
Language : German

http://madtrackers.forumotion.com

Back to top Go down

Solved Re: HTML problem

Post by cheap jeep June 2nd 2009, 7:10 pm

Has anyone found the problem yet? Wink
avatar
cheap jeep
Forumember

Posts : 28
Reputation : 0
Language : German

http://madtrackers.forumotion.com

Back to top Go down

Solved Re: HTML problem

Post by Sanket June 2nd 2009, 8:00 pm

May I remind you that double/triple posting isn't tolerated unless separated by 24 hours (Use the edit button) Wink
Sanket
Sanket
ForumGuru

Male Posts : 48766
Reputation : 2830
Language : English
Location : Mumbai

Back to top Go down

Solved Re: HTML problem

Post by cheap jeep June 2nd 2009, 8:04 pm

Ok... Sad
Can you help me anyway? Smile
avatar
cheap jeep
Forumember

Posts : 28
Reputation : 0
Language : German

http://madtrackers.forumotion.com

Back to top Go down

Solved Re: HTML problem

Post by Sanket June 2nd 2009, 8:05 pm

A portal widget cannot have head & body tags, its for a whole html page.
Sanket
Sanket
ForumGuru

Male Posts : 48766
Reputation : 2830
Language : English
Location : Mumbai

Back to top Go down

Solved Re: HTML problem

Post by cheap jeep June 2nd 2009, 9:49 pm

But what do I need to change? Smile
Pls post working code here Wink
avatar
cheap jeep
Forumember

Posts : 28
Reputation : 0
Language : German

http://madtrackers.forumotion.com

Back to top Go down

Solved Re: HTML problem

Post by cheap jeep June 3rd 2009, 3:22 pm

Please help me! It's a big problem for me! Sad
avatar
cheap jeep
Forumember

Posts : 28
Reputation : 0
Language : German

http://madtrackers.forumotion.com

Back to top Go down

Solved Re: HTML problem

Post by Sanket June 3rd 2009, 4:37 pm

I am not sure if it will work. Sorry.
Sanket
Sanket
ForumGuru

Male Posts : 48766
Reputation : 2830
Language : English
Location : Mumbai

Back to top Go down

Solved Re: HTML problem

Post by Guest June 3rd 2009, 6:11 pm

Are you looking for the code to follow you down the screen when you scroll down, The image with link then would be 'Floating', Is that what your aiming for?

regards









Craig
avatar
Guest
Guest


Back to top Go down

Solved Re: HTML problem

Post by cheap jeep June 3rd 2009, 6:23 pm

No, I want a random image on portal...
avatar
cheap jeep
Forumember

Posts : 28
Reputation : 0
Language : German

http://madtrackers.forumotion.com

Back to top Go down

Solved Re: HTML problem

Post by Guest June 3rd 2009, 6:26 pm

Do you want the image to change every time the page reloads?

Regards






Craig
avatar
Guest
Guest


Back to top Go down

Solved Re: HTML problem

Post by cheap jeep June 3rd 2009, 6:28 pm

Yeah... Or even every minute...
avatar
cheap jeep
Forumember

Posts : 28
Reputation : 0
Language : German

http://madtrackers.forumotion.com

Back to top Go down

Solved Re: HTML problem

Post by Guest June 3rd 2009, 6:42 pm

Ok let me come up with a code for you that works Very Happy

Regards








Craig
avatar
Guest
Guest


Back to top Go down

Solved Re: HTML problem

Post by Guest June 3rd 2009, 7:43 pm

Double post but not intentional

Try this code out

In the head of the page add the following:

Code:
<script language="JavaScript">

<!-- Hide from old browsers

iArray=new Array
(
"images.jpg",
"images.jpg",
"images.jpg",
"images.jpg",
"images.jpg",
"images.jpg",
"images.jpg",
"images.jpg",
"images.jpg",
"images.jpg"
);
ri=Math.floor(iArray.length*Math.random());
ri='<IMG SRC="./'+ iArray[ri]+ '" BORDER="1">';
// end hiding -->

</script>


In the body of the page (Where you want the images to show) add the following code:

Code:
  <script language="JavaScript">
  <!--
  document.write(ri);
  // -->
  </script>

The above codes worked on my test site modules Very Happy

Regards







Craig
avatar
Guest
Guest


Back to top Go down

Solved Re: HTML problem

Post by cheap jeep June 3rd 2009, 7:45 pm

Thank you!
I'll test now.
avatar
cheap jeep
Forumember

Posts : 28
Reputation : 0
Language : German

http://madtrackers.forumotion.com

Back to top Go down

Solved Re: HTML problem

Post by Guest June 3rd 2009, 7:49 pm

Fingers crossed Very Happy lol

regards







Craig
avatar
Guest
Guest


Back to top Go down

Solved Re: HTML problem

Post by cheap jeep June 3rd 2009, 9:43 pm

Now it works!!
I had to remove the comments, they made it not work...
So now, first of all thank you.
I'm the happiest person on the world now.
-thread closed- (in my eyes) Very Happy
avatar
cheap jeep
Forumember

Posts : 28
Reputation : 0
Language : German

http://madtrackers.forumotion.com

Back to top Go down

Solved Re: HTML problem

Post by Sanket June 4th 2009, 3:38 pm

Since this thread appears to be solved, I will lock this thread and mark it as solved.
Sanket
Sanket
Sanket
ForumGuru

Male Posts : 48766
Reputation : 2830
Language : English
Location : Mumbai

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum