Current location: Hot Scripts Forums » General Web Coding » JavaScript » Onmouseover


Onmouseover

Reply
  #1 (permalink)  
Old 10-19-09, 10:43 PM
Tunixer Tunixer is offline
New Member
 
Join Date: Oct 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Onmouseover

Hi, i want to improve my site but having no money to get an expert on it , i came into a brick wall,when i tryed to implement "onmouseover" . The thingy is that i want when i move the mouse on the text to make an image to appear right next to the mouse cursor.

pls explain the code , expecially the parts that i need to adapt to my database , such as //this is where you must write yours this or that

regards

To make an ideea: Download Games, Movies, Programs, Music, Online Movies, Hub List, Torrents - Articles: Filme

Script:
PHP Code:

<?php
require_once "../maincore.php";
require_once 
THEMES."templates/admin_header_mce.php";
include 
LOCALE.LOCALESET."admin/articles.php";

if (!
checkrights("A") || !defined("iAUTH") || $_GET['aid'] != iAUTH) { redirect("../index.php"); }

if (
$settings['tinymce_enabled'] == 1) {
    echo 
"<script language='javascript' type='text/javascript'>advanced();</script>\n";
} else {
    require_once 
INCLUDES."html_buttons_include.php";
}

if (isset(
$_GET['status']) && !isset($message)) {
    if (
$_GET['status'] == "sn") {
        
$message $locale['410'];
    } elseif (
$_GET['status'] == "su") {
        
$message $locale['411'];
    } elseif (
$_GET['status'] == "del") {
        
$message $locale['412'];
    }
    if (
$message) {    echo "<div class='admin-message'>".$message."</div>\n"; }
}

$result dbquery("SELECT * FROM ".DB_ARTICLE_CATS);
if (
dbrows($result)) {
    if (isset(
$_POST['save'])) {
        
$subject stripinput($_POST['subject']);
        
$body addslash($_POST['body']);
        
$body2 addslash($_POST['body2']);
        
$draft = isset($_POST['article_draft']) ? "1" "0";
        if (
$settings['tinymce_enabled'] != 1) { $breaks = isset($_POST['line_breaks']) ? "y" "n"; } else { $breaks "n"; }
        
$comments = isset($_POST['article_comments']) ? "1" "0";
        
$ratings = isset($_POST['article_ratings']) ? "1" "0";
        if (isset(
$_POST['article_id']) && isnum($_POST['article_id'])) {
            
$result dbquery("UPDATE ".DB_ARTICLES." SET article_cat='".intval($_POST['article_cat'])."', article_subject='$subject', article_snippet='$body', article_article='$body2', article_draft='$draft', article_breaks='$breaks', article_allow_comments='$comments', article_allow_ratings='$ratings' WHERE article_id='".$_POST['article_id']."'");
            
redirect(FUSION_SELF.$aidlink."&status=su");
        } else {
            
$result dbquery("INSERT INTO ".DB_ARTICLES." (article_cat, article_subject, article_snippet, article_article, article_draft, article_breaks, article_name, article_datestamp, article_reads, article_allow_comments, article_allow_ratings) VALUES ('".intval($_POST['article_cat'])."', '$subject', '$body', '$body2', '$draft', '$breaks', '".$userdata['user_id']."', '".time()."', '0', '$comments', '$ratings')");
            
redirect(FUSION_SELF.$aidlink."&status=sn");
        }
    } else if (isset(
$_POST['delete']) && (isset($_POST['article_id']) && isnum($_POST['article_id']))) {
        
$result dbquery("DELETE FROM ".DB_ARTICLES." WHERE article_id='".$_POST['article_id']."'");
        
$result dbquery("DELETE FROM ".DB_COMMENTS." WHERE comment_item_id='".$_POST['article_id']."' and comment_type='A'");
        
$result dbquery("DELETE FROM ".DB_RATINGS." WHERE rating_item_id='".$_POST['article_id']."' and rating_type='A'");
        
redirect(FUSION_SELF.$aidlink."&status=del");
    } else {
        if (isset(
$_POST['preview'])) {
            
$article_cat $_POST['article_cat'];
            
$subject stripinput($_POST['subject']);
            
$body phpentities(stripslash($_POST['body']));
            
$body2 phpentities(stripslash($_POST['body2']));
            
$bodypreview str_replace("src='".str_replace("../"""IMAGES_A), "src='".IMAGES_Astripslash($_POST['body']));
            
$body2preview str_replace("src='".str_replace("../"""IMAGES_A), "src='".IMAGES_Astripslash($_POST['body2']));
            
$draft = isset($_POST['article_draft']) ? " checked='checked'" "";
            if (isset(
$_POST['line_breaks'])) {
                
$breaks " checked='checked'";
                
$bodypreview nl2br($bodypreview);
                
$body2preview nl2br($body2preview);
            } else {
                
$breaks "";
            }
            
$comments = isset($_POST['article_comments']) ? " checked='checked'" "";
            
$ratings = isset($_POST['article_ratings']) ? " checked='checked'" "";
            
opentable($subject);
            echo 
$bodypreview."\n";
            
closetable();
            
opentable($subject);
            echo 
$body2preview."\n";
            
closetable();
        }
        
$result dbquery("SELECT * FROM ".DB_ARTICLES." ORDER BY article_draft DESC, article_datestamp DESC");
        if (
dbrows($result)) {
            
$editlist ""$sel "";
            while (
$data dbarray($result)) {
                if ((isset(
$_POST['article_id']) && isnum($_POST['article_id'])) || (isset($_GET['article_id']) && isnum($_GET['article_id']))) {
                    
$article_id = isset($_POST['article_id']) ? $_POST['article_id'] : $_GET['article_id'];
                    
$sel = ($article_id == $data['article_id'] ? " selected='selected'" "");
                } else {
                    
$sel "";
                }
                
$editlist .= "<option value='".$data['article_id']."'".$sel.">".($data['article_draft'] ? $locale['433']." " "").$data['article_subject']."</option>\n";
            }
            
opentable($locale['402']);
            echo 
"<div style='text-align:center'>\n<form name='selectform' method='post' action='".FUSION_SELF.$aidlink."&amp;action=edit'>\n";
            echo 
"<select name='article_id' class='textbox' style='width:250px;'>\n".$editlist."</select>\n";
            echo 
"<input type='submit' name='edit' value='".$locale['420']."' class='button' />\n";
            echo 
"<input type='submit' name='delete' value='".$locale['421']."' onclick='return DeleteArticle();' class='button' />\n";
            echo 
"</form>\n</div>\n";
            
closetable();
        }

        if ((isset(
$_GET['action']) && $_GET['action'] == "edit") && (isset($_POST['article_id']) && isnum($_POST['article_id'])) || (isset($_GET['article_id']) && isnum($_GET['article_id']))) {
            
$result dbquery("SELECT * FROM ".DB_ARTICLES." WHERE article_id='".(isset($_POST['article_id']) ? $_POST['article_id'] : $_GET['article_id'])."'");
            if (
dbrows($result)) {
                
$data dbarray($result);
                
$article_cat $data['article_cat'];
                
$subject $data['article_subject'];
                
$body phpentities(stripslashes($data['article_snippet']));
                
$body2 phpentities(stripslashes($data['article_article']));
                
$draft $data['article_draft'] ? " checked='checked'" "";
                
$breaks $data['article_breaks'] == "y" " checked='checked'" "";
                
$comments $data['article_allow_comments'] ? " checked='checked'" "";
                
$ratings $data['article_allow_ratings'] ? " checked='checked'" "";
            } else {
                
redirect(FUSION_SELF.$aidlink);
            }
        }
        if ((isset(
$_POST['article_id']) && isnum($_POST['article_id'])) || (isset($_GET['article_id']) && isnum($_GET['article_id']))) {
            
opentable($locale['401']);
        } else {
            if (!isset(
$_POST['preview'])) {
                
$subject "";
                
$body "";
                
$body2 "";
                
$draft "";
                
$breaks " checked='checked'";
                
$comments " checked='checked'";
                
$ratings " checked='checked'";
            }
            
opentable($locale['400']);
        }
        
$result dbquery("SELECT * FROM ".DB_ARTICLE_CATS." ORDER BY article_cat_name DESC");
        
$catlist ""$sel "";
        while (
$data dbarray($result)) {
            if (isset(
$article_cat)) $sel = ($article_cat == $data['article_cat_id'] ? " selected='selected'" "");
            
$catlist .= "<option value='".$data['article_cat_id']."'$sel>".$data['article_cat_name']."</option>\n";
        }
        echo 
"<form name='inputform' method='post' action='".FUSION_SELF.$aidlink."' onsubmit='return ValidateForm(this)'>\n";
        echo 
"<table cellpadding='0' cellspacing='0' class='center'>\n<tr>\n";
        echo 
"<td width='100' class='tbl'>".$locale['422']."</td>\n";
        echo 
"<td class='tbl'><select name='article_cat' class='textbox' style='width:250px;'>".$catlist."</select></td>\n";
        echo 
"</tr>\n<tr>\n";
        echo 
"<td width='100' class='tbl'>".$locale['423']."</td>\n";
        echo 
"<td class='tbl'><input type='text' name='subject' value='$subject' class='textbox' style='width:250px;' /></td>\n";
        echo 
"</tr>\n<tr>\n";
        echo 
"<td valign='top' width='100' class='tbl'>".$locale['424']."</td>\n";
        echo 
"<td class='tbl'><textarea name='body' cols='95' rows='5' class='textbox' style='width:98%'>".$body."</textarea></td>\n";
        echo 
"</tr>\n";
        if (
$settings['tinymce_enabled'] != 1) {
            echo 
"<tr>\n<td class='tbl'></td>\n<td class='tbl'>\n";
            echo 
display_html("inputform""body"truetruetrueIMAGES_A);
            echo 
"</td>\n</tr>\n";
        }
        echo 
"<tr>\n<td valign='top' width='100' class='tbl'>".$locale['425']."</td>\n";
        echo 
"<td class='tbl'><textarea name='body2' cols='95' rows='10' class='textbox' style='width:98%'>".$body2."</textarea></td>\n";
        echo 
"</tr>\n";
        if (
$settings['tinymce_enabled'] != 1) {
            echo 
"<tr>\n<td class='tbl'></td><td class='tbl'>\n";
            echo 
"<input type='button' value='".$locale['432']."' class='button' style='width:80px;' onclick=\"insertText('body2', '<--PAGEBREAK-->');\" />\n";
            echo 
display_html("inputform""body2"truetruetrueIMAGES_A);
            echo 
"</td>\n</tr>\n";
        }
        echo 
"<tr>\n";
        echo 
"<td class='tbl'></td><td class='tbl'>\n";
        echo 
"<label><input type='checkbox' name='article_draft' value='yes'".$draft." /> ".$locale['426']."</label><br />\n";
        if (
$settings['tinymce_enabled'] != 1) { echo "<label><input type='checkbox' name='line_breaks' value='yes'".$breaks." /> ".$locale['427']."</label><br />\n"; }
        echo 
"<label><input type='checkbox' name='article_comments' value='yes'".$comments." /> ".$locale['428']."</label><br />\n";
        echo 
"<label><input type='checkbox' name='article_ratings' value='yes'".$ratings." /> ".$locale['429']."</label></td>\n";
        echo 
"</tr>\n<tr>\n";
        echo 
"<td align='center' colspan='2' class='tbl'><br />\n";
        if ((isset(
$_POST['article_id']) && isnum($_POST['article_id'])) || (isset($_GET['article_id']) && isnum($_GET['article_id']))) {
            echo 
"<input type='hidden' name='article_id' value='".(isset($_POST['article_id']) ? $_POST['article_id'] : $_GET['article_id'])."' />\n";
        }
        echo 
"<input type='submit' name='preview' value='".$locale['430']."' class='button' />\n";
        echo 
"<input type='submit' name='save' value='".$locale['431']."' class='button' /></td>\n";
        echo 
"</tr>\n</table>\n</form>\n";
        
closetable();
        echo 
"<script type='text/javascript'>"."\n"."function DeleteArticle() {\n";
        echo 
"return confirm('".$locale['451']."');\n}\n";
        echo 
"function ValidateForm(frm) {"."\n"."if(frm.subject.value=='') {\n";
        echo 
"alert('".$locale['450']."');"."\n"."return false;\n}\n}\n</script>\n";
    }
} else {
    
opentable($locale['403']);
    echo 
"<div style='text-align:center'>".$locale['452']."<br />\n".$locale['453']."<br />\n";
    echo 
"<a href='article_cats.php".$aidlink."'>".$locale['454']."</a>".$locale['455']."</div>\n";
    
closetable();
}

require_once 
THEMES."templates/footer.php";
?>

Last edited by job0107; 10-20-09 at 02:31 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 10-20-09, 08:49 AM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
Attaching an image to the mouse pointer is kind of simple.
I have attached the onmousemove event to the document so the image element always follows the mouse pointer.

In the image element I use the onmouseover event listener to assign an image to the image element and make it visible.
And I use the onmouseout event listener to make the image element invisible.
HTML Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<head>
<title></title>
<style>
span{
 cursor:pointer;
 color:blue;
}
#img1{
 position:absolute;
 width:100px;
 height:100px;
 display:none;
}
</style>
<script type="text/javascript">
var y_offset = 10;
var x_offset = 15;
function moveImage(){
 document.getElementById('img1').style.top = event.y + y_offset + "px";
 document.getElementById('img1').style.left = event.x + x_offset + "px";
}
function moveImageMOZ(e){
 document.getElementById('img1').style.top = e.pageY + y_offset + "px";
 document.getElementById('img1').style.left = e.pageX + x_offset + "px";
}
function showImage(obj){
 document.getElementById('img1').src = obj;
 document.getElementById('img1').alt = obj;
 document.getElementById('img1').style.display = "block";
}
function hideImage(){
 document.getElementById('img1').style.display = "none";
}
if(!document.all){
 window.captureEvents(Event.mouseMove);
 window.onmousemove=moveImageMOZ;
}
else{document.onmousemove=moveImage;}
</script>
</head>
<body>
Take a look at <span onmouseover="showImage('image1.jpg');" onmouseout="hideImage();"><i><b><u>image 1</u></b></i></span>.
<br /><br />
Take a look at <span onmouseover="showImage('image2.jpg');" onmouseout="hideImage();"><i><b><u>image 2</u></b></i></span>.
<img id="img1" src="" alt="" />
</body>
</html>
__________________
Jerry Broughton
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
OnMouseOver problem RevWaters PHP 4 04-13-09 08:10 AM
onMouseOver / Out problem jonnekke JavaScript 1 08-05-08 09:31 AM
onmouseover effect Ares JavaScript 22 05-20-06 01:51 PM
onMouseOver works on my computer, but not online naomiomio JavaScript 4 03-04-06 03:02 PM
I need a script for onMouseOver, image zooming + fading AgentRed Script Requests 0 09-06-04 07:21 PM


All times are GMT -5. The time now is 12:15 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.