Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying random content on other websites

Status
Not open for further replies.

shockyz

Technical User
Nov 13, 2009
3
RS
Hello,

I have a simple script for showing my content (pictures) on other websites, but it generates the content by reading the users date (1-31), and because of that can show only certain amount of content/pictures (31) on a mountly bases. Can I edit this simple script to randomize the way the content is being displayed, so I'll be able to display a greater number of content?

Example of the way the content is displayed:
http://www.girlsonwallpapers.com/test.html

Code that displays the script:
Code:
<script language="JavaScript" src="[URL unfurl="true"]http://www.girlsonwallpapers.com/girls.js"></script>[/URL]

Script:
Code:
var msg = new Array();
Stamp = new Date();
today = Stamp.getDate();
msg[1] = "<a target=_blank href=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/megan-fox3.jpg><img[/URL] src=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/m-megan-fox3.jpg[/URL] width=93 height=70 border=0></a>";
msg[2] = "<a target=_blank href=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/megan-fox3.jpg><img[/URL] src=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/m-megan-fox3.jpg[/URL] width=93 height=70 border=0></a>";
msg[3] = "<a target=_blank href=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/megan-fox3.jpg><img[/URL] src=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/m-megan-fox3.jpg[/URL] width=93 height=70 border=0></a>";
msg[4] = "<a target=_blank href=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/megan-fox3.jpg><img[/URL] src=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/m-megan-fox3.jpg[/URL] width=93 height=70 border=0></a>";
msg[5] = "<a target=_blank href=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/megan-fox3.jpg><img[/URL] src=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/m-megan-fox3.jpg[/URL] width=93 height=70 border=0></a>";
msg[6] = "<a target=_blank href=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/megan-fox3.jpg><img[/URL] src=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/m-megan-fox3.jpg[/URL] width=93 height=70 border=0></a>";
msg[7] = "<a target=_blank href=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/megan-fox3.jpg><img[/URL] src=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/m-megan-fox3.jpg[/URL] width=93 height=70 border=0></a>";
msg[8] = "<a target=_blank href=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/megan-fox3.jpg><img[/URL] src=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/m-megan-fox3.jpg[/URL] width=93 height=70 border=0></a>";
msg[9] = "<a target=_blank href=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/megan-fox3.jpg><img[/URL] src=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/m-megan-fox3.jpg[/URL] width=93 height=70 border=0></a>";
msg[10] = "<a target=_blank href=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/megan-fox3.jpg><img[/URL] src=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/m-megan-fox3.jpg[/URL] width=93 height=70 border=0></a>";
msg[11] = "<a target=_blank href=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/megan-fox3.jpg><img[/URL] src=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/m-megan-fox3.jpg[/URL] width=93 height=70 border=0></a>";
msg[12] = "<a target=_blank href=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/megan-fox3.jpg><img[/URL] src=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/m-megan-fox3.jpg[/URL] width=93 height=70 border=0></a>";
msg[13] = "<a target=_blank href=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/megan-fox3.jpg><img[/URL] src=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/m-megan-fox3.jpg[/URL] width=93 height=70 border=0></a>";
msg[14] = "<a target=_blank href=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/megan-fox3.jpg><img[/URL] src=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/m-megan-fox3.jpg[/URL] width=93 height=70 border=0></a>";
msg[15] = "<a target=_blank href=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/megan-fox3.jpg><img[/URL] src=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/m-megan-fox3.jpg[/URL] width=93 height=70 border=0></a>";
msg[16] = "<a target=_blank href=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/megan-fox3.jpg><img[/URL] src=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/m-megan-fox3.jpg[/URL] width=93 height=70 border=0></a>";
msg[17] = "<a target=_blank href=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/megan-fox3.jpg><img[/URL] src=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/m-megan-fox3.jpg[/URL] width=93 height=70 border=0></a>";
msg[18] = "<a target=_blank href=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/megan-fox3.jpg><img[/URL] src=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/m-megan-fox3.jpg[/URL] width=93 height=70 border=0></a>";
msg[19] = "<a target=_blank href=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/megan-fox3.jpg><img[/URL] src=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/m-megan-fox3.jpg[/URL] width=93 height=70 border=0></a>";
msg[20] = "<a target=_blank href=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/megan-fox3.jpg><img[/URL] src=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/m-megan-fox3.jpg[/URL] width=93 height=70 border=0></a>";
msg[21] = "<a target=_blank href=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/megan-fox3.jpg><img[/URL] src=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/m-megan-fox3.jpg[/URL] width=93 height=70 border=0></a>";
msg[22] = "<a target=_blank href=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/megan-fox3.jpg><img[/URL] src=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/m-megan-fox3.jpg[/URL] width=93 height=70 border=0></a>";
msg[23] = "<a target=_blank href=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/megan-fox3.jpg><img[/URL] src=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/m-megan-fox3.jpg[/URL] width=93 height=70 border=0></a>";
msg[24] = "<a target=_blank href=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/megan-fox3.jpg><img[/URL] src=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/m-megan-fox3.jpg[/URL] width=93 height=70 border=0></a>";
msg[25] = "<a target=_blank href=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/megan-fox3.jpg><img[/URL] src=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/m-megan-fox3.jpg[/URL] width=93 height=70 border=0></a>";
msg[26] = "<a target=_blank href=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/megan-fox3.jpg><img[/URL] src=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/m-megan-fox3.jpg[/URL] width=93 height=70 border=0></a>";
msg[27] = "<a target=_blank href=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/megan-fox3.jpg><img[/URL] src=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/m-megan-fox3.jpg[/URL] width=93 height=70 border=0></a>";
msg[28] = "<a target=_blank href=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/megan-fox3.jpg><img[/URL] src=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/m-megan-fox3.jpg[/URL] width=93 height=70 border=0></a>";
msg[29] = "<a target=_blank href=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/megan-fox3.jpg><img[/URL] src=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/m-megan-fox3.jpg[/URL] width=93 height=70 border=0></a>";
msg[30] = "<a target=_blank href=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/megan-fox3.jpg><img[/URL] src=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/m-megan-fox3.jpg[/URL] width=93 height=70 border=0></a>";
msg[31] = "<a target=_blank href=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/megan-fox3.jpg><img[/URL] src=[URL unfurl="true"]http://www.girlsonwallpapers.com/megan-fox/m-megan-fox3.jpg[/URL] width=93 height=70 border=0></a>";

function writeTip() { 
document.write(msg[today]);
}
document.write(msg[today]);
document.write('<br>[<a <a target=_blank href="[URL unfurl="true"]http://www.girlsonwallpapers.com">girlsonwallpapers.com</a>[/URL]]');

Thanx ;)
 
Hi

I would do it like this :
JavaScript:
[b]var[/b] msg[teal]=[[/teal] [gray]// thumbnail image, full size image, thumbnail width, thumbnail height[/gray]
  [teal][[/teal][green][i]'/megan-fox/megan-fox3.jpg'[/i][/green][teal],[/teal][green][i]'/megan-fox/m-megan-fox3.jpg'[/i][/green][teal],[/teal][purple]93[/purple][teal],[/teal][purple]70[/purple][teal]],[/teal]
  [teal][[/teal][green][i]'/other/thumb.jpg'[/i][/green][teal],[/teal][green][i]'/other/original.jpg'[/i][/green][teal],[/teal][purple]120[/purple][teal],[/teal][purple]50[/purple][teal]],[/teal]
  [teal][[/teal][green][i]'/more/small.jpg'[/i][/green][teal],[/teal][green][i]'/other/big.jpg'[/i][/green][teal],[/teal][purple]100[/purple][teal],[/teal][purple]66[/purple][teal]][/teal]
[teal]][/teal]

[b]var[/b] rand[teal]=[/teal]Math[teal].[/teal][COLOR=darkgoldenrod]floor[/color][teal]([/teal]Math[teal].[/teal][COLOR=darkgoldenrod]random[/color][teal]()*[/teal]msg[teal].[/teal]length[teal])[/teal]

document[teal].[/teal][COLOR=darkgoldenrod]write[/color][teal]([/teal][green][i]'<a href="'[/i][/green][teal]+[/teal]msg[teal][[/teal]rand[teal]][[/teal][purple]0[/purple][teal]]+[/teal][green][i]'" target="_blank"><img src="'[/i][/green][teal]+[/teal]msg[teal][[/teal]rand[teal]][[/teal][purple]1[/purple][teal]]+[/teal][green][i]'" alt="random girl photo" width="'[/i][/green][teal]+[/teal]msg[teal][[/teal]rand[teal]][[/teal][purple]2[/purple][teal]]+[/teal][green][i]'" height="'[/i][/green][teal]+[/teal]msg[teal][[/teal]rand[teal]][[/teal][purple]3[/purple][teal]]+[/teal][green][i]'"></a>'[/i][/green][teal])[/teal]

document[teal].[/teal][COLOR=darkgoldenrod]write[/color][teal]([/teal][green][i]'<br>[<a <a target="_blank" href="[URL unfurl="true"]http://girlsonwallpapers.com/">girlsonwallpapers.com</a>[/URL]]'[/i][/green][teal])[/teal]
Next time please cut off redundant code. Was no need to post the assignment of all 31 identical array elements.

Feherke.
 
Was no need to post the assignment of all 31 identical array elements.

Unless it was an attempt to get SEO for the site ;-)



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
You're right for the long version of code, sorry...

Thank you feherke! ;)

The only two thins I'm missing in this one are the inability to place the script in the other site than the one wich has the source of the linked files. That's because it reads the source from the directory/site the script has been placed.

As for the second thing, I would like to manage the thumb border width.

Thanx again...
 
It's ok, I figured it out... ;)

Thanx feherke,
Milos
 
Hi

Milos said:
As for the second thing, I would like to manage the thumb border width.
Yes, I saw that you had [tt]border[/tt] attributes in your [tt]img[/tt] tags. And you had no [tt]alt[/tt] attributes. I altered abit the generated HTML because
[ul]
[li]the [tt]border[/tt] attribute is deprecated, use CSS instead[/li]
[li]the [tt]alt[/tt] attribute is required[/li]
[/ul]
Beside that, if the script will appear in "other site", deciding on the border's appearance should be that other site's job.


Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top