MySpace Dev. 3: The div overlay method
Yesterday, I covered some basic architectural guidelines for building a navigable MySpace page. Now that we have some basic idea of what to build (or, hopefully, a PSD mockup of what we want to build,) it’s time to get into the HTML/CSS.
What, though, is giving us this creative freedom? If you’ve read over the fine print on the MySpace Safe Mode page, supposedly DHTML is allowed; however, JavaScript — the dynamic part of DHTML — isn’t, due to the ability to build XSS exploits and other malicious scripts. For our case, then, the D in MySpace’s DHTML must stand for damaged.
By default, the MySpace codebase renders itself in quirks mode due to the HTML 4.01 Document Type Declaration without a SYSTEM identifier. (For those not speaking W3C speak, it’s got an old architecture.) To make things worse, you, too, are stuck writing quirks mode code thanks to MySpace’s heavy HTML/CSS parsing limitations. On the HTML end, MySpace strips <script>, <object>, and <iframe> upon form submission. However, we see people embed Flash and movies into their profiles all the time. They’re using the Netscape-based, long-since-deprecated <embed> tag, read by Mozilla, KHTML (Konqueror and AppleWebKit/Safari), and IE for backwards compatibility.
The CSS abilities allowed by MySpace are also broken. MySpace disallows any CSS using the id selector (#), so all targeted markup must use the class attribute. This filter also destroys hexadecimal colours, ruling out the use of shortcuts (such as #fff) and those CSS properties with hexadecimal colour inline (font, border, etc.) For some unknown reason, MySpace was also breaking directly before a font-family declaration in the body properties of my CSS with .r { }, ruining the font-family and anything underneath. (I assume that this is a bug in the parser; this makes very little sense to me on the frontend.)
That means that our HTML and CSS will be poorly formed and intentionally broken to work on MySpace. It’s an unfortunate truth of the site, but for all of its shortcomings, we have to thank the MySpace guys for giving us at least something to work with, unlike other networks such as Facebook.
We’re not done with restrictions yet, though. MySpace has one more tucked away at the bottom of its page: the MySpace Terms of Service. In the Prohibited Content section, you’ll notice a few things that are broken constantly: posting e-mail addresses or site URLs, for example. One that MySpace won’t tolerate, however, is obscuring their advertisement at the top of the page. Although the ads that roll through are sometimes garish, unless you want to pay MySpace tens of thousands of dollars (like some have,) your profile page is on a one-way trip to deactivation.
Now that we know what we’re getting into, we have to build some way to 1. hide MySpace’s built-in code and 2. apply our own design to the page without tainting the ad. Although there are many restyling methods, the div overlay method presented by Derek Punsalan at 5thirtyone gives us space to work with while not violating the MySpace TOS. In just a few lines of code, you can effectively lay your own div over myspace and display your own code.
Before we actually write the div overlay code, we need to know where to place it. Using the MySpace Safe Mode, all CSS is inserted in “About Me” and all HTML in “Who I’d like to meet.” By doing this, your CSS will load before your HTML in a proper fashion. To start the div overlay, add this core CSS to “About Me”:
.main {
position:absolute;
left:50%;
top:125px;
width:800px !important;
z-index:1;
margin-left:-400px;
}
</style>
(Obviously, change colours if you see fit, but do not change width or positioning properties.)
With CSS in place, it’s time to add HTML and complete the overlay. Add this code to “Who I’d like to meet”:
<table style="width: 800px;
height: 800px;
cellpadding: 0px;
cellspacing: 0px;
background-color: FFFFFF;">
<tr><td valign="top">
… your content here …
</td></tr></table></div>
<div style="position:relative; height:400px; overflow:hidden; border:0px;"><table><tr><td><table><tr><td>
Now, if you view your profile page, you’ll notice everything below the ad is blank. If information is protruding from the bottom of the div, increase the height of div.main and delete as much content as you can from your profile underneath. If you want some quick example code to work from, Derek has offered his Dark minimal MySpace div overlay for download here.
Now that we have a core overlay, we’ll need to add in our own MySpace interface links. Get your Friend ID, as it’s necessary for most of the links. Core actions are as follows; just replace #friendID# with your friend ID (If you don’t know how to get your friend ID, this tool will help you.)
Send Message
friendID=#friendID#
Add to Friends
friendID=#friendID#
Add to Group
friendID=#friendID#
Forward to Friend
friendID=#friendID#&f=forwardprofile
Add to Favourites
friendID=#friendID#&public=0
Block User
userID=#friendID#
Rank User
UserID=#friendID#
If there are other MySpace interactions you’d like to use, just use Copy Link Location on the link to get its target URI. Generally, you need to replace the number after userID or friendID with your Friend ID.
If it isn’t obvious by the overlay’s effect or its name, everything must be recreated within your overlay. If you want music, you’ll have to recreate it. If you want blog functionality, that, too, must be recreated. Due to interactivity limitations, all of these dynamic elements will have to be done through Flash; the next two tutorials will build code in Flash (or, in the case of the music player, some XML with an existing Flash application) to restore this functionality.
For now, however, HTML and CSS must be written. If you need some direction, you can use my markup. downloadable below. Mind you, the code is Creative Commons-licenced, so do not copy this for commercial purposes. If you’d like more base layouts, Derek has a pack of Minimal MySpace overlays in Lime, Orange, and Pink for download. What are you waiting for? It’s time to get coding.
Correction (10 August 2006) — MySpace changed some CSS and for a while the !important rule was necessary to force the width of div.main. Things have returned to normal now. Go figure. I’m leaving the !important rule in the code for now.
Type a Comment
Incoming Links
- Where can i find…
go to this link for more… - Final exam flight delays at…
On the other end of the theme, I’m going to be building some new WordPress plugins to manage comments. With Akismet filtering almost all of my… - dangerouslyawesome »…
And then, there are some, who hook a brotha up. Some coding genious (or boredom) has struck some individuals, inspiring them to hack apart…
Comments
Tyler
posted 2 years ago
Just as a question, completely out of the blue so a simple no is fine enough. When using the div-overlay method, the rest of the myspace page (comments, etc.) is still sent inside the html document when viewed even though you can’t see it. Is there any way to incorperate this information in an overlaping layout?
Jeffrey Kaine
posted 1 year, 11 months ago
can you tell me whats wrong with this?
i cant seem to get the proportions correct!
Rodney
posted 1 year, 11 months ago
Not really sure if I am correct but, when trying to use your .main and after having difficulty not having things happen the way they should. I looked at the profiles page source and found out that it is now named .tipDiv again I could be wrong but when using the .tipDiv everything seemed to work for the better. Great help here also, thanks!
Warren
posted 1 year, 11 months ago
Your code doesn\’t appear to do anything at all. I was using Netscape. I switched to EI6 to see if this was the problem. It was not, the code still does nothing to the profile. I have tripple checked the code, and made sure it is placed where you saw to place it. It is all correct. I have just switched to Firefox, to see if this corrects the problem, it does not. Your code appears to do nothing.
Here is the profile.
Rodney
posted 1 year, 11 months ago
Warren and any others:
to get the above code to work you need to replace ALL
.main to .tipDiv
you will lose the bottom page links; About, Faq, etc. and it will aalso cover the top links (not the ad) mess around with it eventually you will get it
Eston Bond
posted 1 year, 11 months ago
Rodney and Warren:
I’ve tracked down the problem and fixed it accordingly. For some reason, something in the MySpace CSS has changed and now you have to force the width of
div.mainusing the!importantrule. I’ve updated the code above to use it.As for the
tipDivthing, Rodney, that’s not a stable way to solve the overlay issue. Sure, it creates a much larger overlay, but it obscures upper navigation, which contains multiple instances ofmyTokenand login-specific links that you can’t easily replace. Breaking a lot of that can violate some common usability rules.Update (10 August 2006 23:12) — Weird. I had a chat with Derek since I pretty much directly copied his code in this instance, and when I went to replicate (for a third time) I couldn’t reproduce the bug. MySpace must’ve changed something temporarily, but you should be good now. I’ve left the
!importantrule in in case this happens again.shegangsta
posted 1 year, 10 months ago
Question….do you know of any program to make a custom div overlay? Because, I want to create my own images and graphics or whatever….but I can’t do what I want to with just copy and pasting codes….
thanks
Eston Bond
posted 1 year, 10 months ago
shegangsta:
There are plenty that exist, but that’s not the purpose of this tutorial. Just search Google for them.
The only way to make a truly custom MySpace profile is to code it by hand. :)
Jon
posted 1 year, 10 months ago
I’m brand new to myspace programming, but a veteran in web design. I’ve stumbled across the div overlay by 5thirtyone, but find it breaking in version 3 of Internet Explorer 7. It also breaks on a refresh in Internet Explorer 6, but the case is much more tolerabe. I’m about to embark on committing myself to professional myspace pages, and have several key clients ready to go. However, without a cross browser 100% compatible in this case centered div, I think it may put me back on the drawing board of working within the confines of myspace’s horrible nested table layout.
Oddly enough the script works perfect in IE7, but there is something holding it back within myspace. Even creating an absolute div set to 100% width will only account for it’s container table of 435px. My goal was to create a 100% wide and high div, then center div’s within it, but its been quite difficult. I’m almost to the point of creating a Flash doc on top of everything, but I don’t want to stray from html, even I use a Flash blocker within my Firefox. I’m continuing trying to figure out a solution.
Scott
posted 1 year, 10 months ago
I’ve seen this question posted on many forums, but there are never any responses to it, which leads me to believe it either can’t be done, or those who have figured it out do not wish to share the method they used.
When setting up a custom div-overlay on myspace, it’s easy to add in a scrollable box for comment submission as well as adding a link to view your comments on the generic myspace page. But, is it possible to dynamically grab all of your comment data and display them at the very bottom of your overlay in a separate div? I’ve seen pages with this done, but its possible that they are statically coding in all of their comments, which I would rather not do if the option is there. This requires an update to your code every time a new comment is submitted. It would be nice to dynamically display them on your overlay.
I have tried setting up .comt in my style sheet with all of the correct table data, and then creating a new div with class=”comt”. I’ve even adjusted all of the positions relative to left and top, but I can not seem to get them to display. Has anybody successfully gotten this working yet?
h4xor66
posted 1 year, 10 months ago
i saw the comments being displayed effectivly in this div … guess you can read the code and figure it out
http://www.createblog.com/layouts/download.php?id=14122
ben Montes
posted 1 year, 9 months ago
i used a style sheet on my profile but it’s not viewing effectively on safari, i’m not sure what kind of style sheet to make to select as a viewing option for my computer…and honestly i don’t know where to make it. i thought i was making some progress when i selected your myspace css for my safari preferences…but that didn’t work either…..
argh.
and thanks.
joey
posted 1 year, 9 months ago
i have a div overlay on my myspace and it will not allow me to embed a video from http://www.youtube.com into it. All i see is the width and height as text and “…” will you please help me?
-Joey
Marc
posted 1 year, 9 months ago
Heya. If anyone wants a working example of a DIV comment box that updates automatically then check my profile:
http://www.myspace.com/mahspak
Rip my source apart if you like.
** QUESTION: **
I would also like to know how to re-create a table inside a DIV that can display content from the ‘Music, General’.. ect Fields. Ive looked into loading XML data into flash but then i thought “why?” myspace has perfectly good Data that can be added and updated from the fields in the Edit Profile page.
There must be a way. I just hope someone knows what the table is called that hols the General and Music..ect Data.
Any ideas!?
Eston Bond
posted 1 year, 9 months ago
Marc:
Please send me your “official” code for the box and I’ll place it a user-contributed pack due out here next Monday. This goes for the rest of you as well; if you have some code you’d want to go into the repository that deals with the Hack Pack, let me know and maybe it’ll be included next week.
Mitch
posted 1 year, 9 months ago
Wow.. Best tutorial ever!! After a nice google search I found your site.. I just wanted to get rid of all that myspace junk so I could make it what I wanted :) And thanks to you now I can.
Wooly
posted 1 year, 8 months ago
Love Wooly
Brian
posted 1 year, 8 months ago
its driving me crazy.. im pretty new to the whole HTML / CSS scene… but i actually picked up on it pretty quick.. however my question is similar if not the same as scott asked earlier… the div overlays for a scrollable comment box… i want to be able to see my comments displayed on my profile inside a box… BUT BUT ive looked through the code and i stumps me… i JUST dont understand what does what as far as the comments go.. or.. i hate to sound like such a noob.. but its been frustrating me… after cramming all this CSS and HTML in my head i feel like its about ready to pop… i know how to get the comments invisible lol…. copy and paste .. that stuff… but why do i have to do that? and what are the last few table tags for?
any help would be grreeaattly appreciated.. thanks in advance!
Jeremy
posted 1 year, 8 months ago
First, to Brian (and several others):
The problem with bringing things like information in the pre-made Myspace format (’About Me’, ”Interests’, etc.) and Comments into an overlay is that when your Profile loads, it queries a backend database for that information and builds the page on-the-fly. The end result is that all you see is the completed HTML code.
The only way around this is figure out the exact query sent to the database for that stuff, then build a Flash widget (like the RSS reader in the next tutorial) to query the database, take the results and format them, then display them in your overlay.
How, exactly does one do that? No clue, there. Most likely, the pages you’ve seen with comments are hardcoded.
Oh, and all those table rows and divides at the end of the code used to hide Comments are so that when the ‘About Me’ table gets closed by the MySpace parser, it only closes off the ‘invisible’ table you just made, letting your hidden Div contain the Comments and hide them.
Second:
I love this tutorial. I avoided MySpace for as long as I could, but needing it for personal and professional reasons, I finally caved. But once I had my account, I was crushed by it’s lack of customization, even through cut-and-paste code snippets from the myriad of sites out there.
This is exactly what I was looking for.
By the way, the PARAM tag isn’t completely lost - EMBED allows you to put certain PARAM tags within the tag itself. Although it doesn’t work for passing parameters (at least, it didn’t when I tried it, but I’m hardly a guru), it will accept some. I used the WMODE param within EMBED and some z-index trickery to place flash animations behind the standard MySpace table layout. The result was noteworthy until an enthusiast friend blew my page layout with an ambitiously large picture in my comments…
Elle Marie
posted 1 year, 8 months ago
It seems like all the information I can find on building DIV overlays is great for the tables but they never show how to alter the font in the specific tables. Anyone able to help me with that?
This is by far the best tutorial I’ve found so far! Thanks :)
Sunny day
posted 1 year, 8 months ago
Hi all and thank you Eston for this tutorials and ressources it’s all I need.
But in one post Marc show us his scrolling comment box, it really what I need and Eston you said that you’ll put this in a user-contributed pack… where can i find it please or only this code?
Thanks
Eston
posted 1 year, 8 months ago
Sunny day:
I don’t think Marc ever sent me his code, and if he did I can’t find it in my Inbox. Since it’s been requested, though, I’ll put a tutorial for it in the queue for Pilot Training entries. Sorry I can’t help you with it immediately — you may want to contact Marc directly and see if he can’t help you out.
michael
posted 1 year, 8 months ago
i have coding for scrollable comments in a myspace div overlay… however i am having compatibility issues with IE, the box displays fine in firefox… with my div overlay i used a combination of photoshop, image ready, fireworks and dreamweaver… if you need tutorials, go to mygen.co.uk and check their forum in the tutorial section… there is a good video tutorial by luvs2dostuf and also a div comment box code… you will need to tweak the numbers to get it to display where you want it, and it will not work in IE, atleast not that i know…
Sunny day
posted 1 year, 8 months ago
i check the tutorial but not the video. i ll check it this evening.
Thanks
Marc
posted 1 year, 7 months ago
Hey, I did email you the code ill send it again soon. Maybe through anouther email address?
Nice to see theres a code that works in FireFox because the comment DIV i use only works in IE atm. So im going to look into michaels code soon.
Eric
posted 1 year, 7 months ago
I’m surprised there’s no tutorials supplying code you can copy and paste for scrollable, live, comment boxes. has anyone come across any?
Native Queen
posted 1 year, 7 months ago
message me kzu my profiles private but I could prolly help with the explorer not sure bout fire fox I have a comment box and upon immediate submit it appearz in my div commentz ..
Gene
posted 1 year, 7 months ago
hey i’ve been trying to find this out everywhere but, how can i implement BG music into a custom div?? im not sure really how to & can’t find it anywhere.
Jessie
posted 1 year, 7 months ago
I don’t know exactly where, but when I’ve typed “Myspace Tweaks” into google, I’ve found tons of sites that list codes for making scrollable myspace comment tables
Jasmine
posted 1 year, 7 months ago
Hey how can I add the “member since” part of a myspace music page? is it possible?
Marc
posted 1 year, 7 months ago
Mygen comment DIV:
http://www.mygen.co.uk/phpbb2/viewtopic.php?p=65238&sid=49ab45c6e5dd5cd5bd2428d948ff3a55
Tatiana
posted 1 year, 6 months ago
The HTML/CSS code above that is available for download doesn’t seem to work. I’ve tried it many times and messed with it a little… but no luck. Maybe it’s just me.
Eston
posted 1 year, 6 months ago
Tatiana:
Try the download in the last entry of this series. Turns out my link was broken up there anyway. All is well now.
Marc
posted 1 year, 6 months ago
Hey, Ive finally found time to make an example or the comment box overlay that i use on my profile.. the script can be found here:
http://www.myspace.com/mahspak1
Please click an ad to make this worth my while! (it took all day)
Pat
posted 1 year, 6 months ago
Hey, I liked your Myspace site and am wondering if you accept offers to design Myspace websites, because I’d certainly commission you to design mine.
Eston
posted 1 year, 6 months ago
Pat:
Yes, I do. If you want to know more about freelance work, e-mail me with the kind of things you’re looking for and we can discuss timeframes and pricing.
KT
posted 1 year, 5 months ago
I am using a practice page to work on my band’s myspace page.
I am relatively new to div overlays, but I feel like I’m getting the hang of it.
The only MAJOR problem I’m having is making the music player appear, along with the comments (and top friends).
I’ve tried every code I can find and nothing seems to be working!!!
I am pulling my skin off, my hair out, and my patience through the roof… I’ve been trying to figure this out for 3 straight weeks, and it’s the ONLY thing keeping me from being finished.
If there is ANYONE out there who can help me, I BEG of you, please contact me at stellanoir@gmail.com
I will be forever in your debt.
Oh, Thank you, thank you.
-KT
Donovan
posted 1 year, 5 months ago
Thanks for the help so far!
But… I’m trying to position my comment section over an image map that must be centered.
So you can see that I need my comments section be placed within a div overlay which would be layered on top of my image map.
Would you have any thoughts?
Tim
posted 1 year, 5 months ago
i want to put a youtube video in my div overlay but whenever i try to put it in it never shows up. what can i do to fix this????/ please help
kelley
posted 1 year, 5 months ago
im trying to figure out how to make a rockyou.com embedded slideshow work in my div layout. anybody know how to do this?
Erica
posted 1 year, 5 months ago
Hi, I just foud your tutorials and site and want to thank you for so many clear tutorials. Although I haven’t used any codes from your site yet, I am sure to use some eventually, as I am not completely satisfied yet with my myspace page.
Recently I found Derek’s minimal lime Div overlay and replaced my myspace page with the code. I am still working on my page, but have made slow but steady progress. CSS code is challenging as a newbie and I am FULL aware that it can consume your entire evening and afternoon(s), lol.
You seem to be very good about answering questions, so I thought I would ask you one that is probably easily fixed but unknown to myself….
After I placed a background image I made on my profile, it seems to have copied and pasted parts of itself in the upper and lower portion of my page. I was wondering if you know how to get rid of that. Ideally I would like to get rid of the lower banner/myspace about links and turn the entire background other than my backgorund image into the pattern located in my comment box. If you have a moment, I would love to hear your advice …here is my page…
http://www.myspace.com/eacreativeworks
chellziie
posted 1 year, 5 months ago
im used to all of the html/css stuff but this overlay thing wont work. =S its not covering anything. :(
Dylan Pritts
posted 1 year, 4 months ago
Im still a bit confuesed, how would i be able too use this to put a layout i made in photoshop on myspace?
Abigail
posted 1 year, 4 months ago
I have been playing with the div.main to try and cover my entire page with the overlay but I cannot seem to do so. It is sneaking out on the left and the bottom right. Any suggestions?? Thanks for your time!
Meah
posted 1 year, 4 months ago
HELP ME! I just have a question! I am making a myspace page that looks more like a website … i have my own little contact table designed and I want to put it somewhere on the page how do I put it there and get the links to work? what codes do I use? am I even making since?? HELP Im under a deadline!! Thanks!!
Eileen
posted 1 year, 4 months ago
Abigail,
My suggestion is to turn things invisible (hidden) and then do a div on top of the empty space, instead of the default profile.
I have some code to do that here:
hiding the default myspace page”
I have a few different options, depending on how much of the top menu/search area you want to hide.
Once you do this, you may need to add an explicit visible to the div overlay.
Meah,
It isn’t that you are not making sense, it is that I have no way of knowing what you have already done to your page. Leave me a message via myspace, I don’t check back here that often. I might be able to help you (no guarantee). And maybe it is already past your deadline.
Evan
posted 1 year, 4 months ago
I’m working on a div for a myspace page and I changed the main color to black and want the sides to be a different color. How do I add the sides as a different color? All thats there is the main div. I’m kinda new at this stuff and learning.
shawn
posted 1 year, 4 months ago
Hi Eston,
Your code rocks. IE doesn’t. I hate IE7’s rendering of the code, you can see the original page peeking out to the left under the div. I certainly didn’t want to move the margin any more into the negative (past -400) because it would wreck the layout on better browsers (btw, Safari and Firefox work splendidly). Any ideas on how to add an IE7 fix?