May 6, 2013

How to make a floating menu appear after you scroll past a certain point?

JonnyBravo’s Questions:

I want to make four menu tabs appear after you scroll past a certain point (ex: 1000px) on the page. I want them to slide in from left to right when they appear. This is what I’m going for, but on the left side of the browser. Any input is appreciated.

Thanks

First you’re going to want to start by tracking the scrolling of the page. Second you’re going to want to animate the divide from left to right when needed. To do this, you’ll need to use the scroll function, and a few others for the animating part.

Here’s a base to what you want, without the scroll.

function slider() {
    if (document.body.scrollTop > 100) //Show the slider after scrolling down 100px
        $('#slider').stop().animate({"margin-left": '0'});
    else
        $('#slider').stop().animate({"margin-left": '-200'}); //200 matches the width of the slider
}

Now you’ll want to fire this function while the user scrolls, using:

$(window).scroll(function () {
    slider();
});

And finally, you’ll also want to call the function when the user first arrives, incase the user starts half way down the page, using:

$(document).ready(function () {
    slider();
});

A few things to note:

I’ve hard coded the sliders width to 200px, and the start point to 100px.
The stop() function is very important and stops the animate function from being called redundantly.

Here’s a working jsfiddle with the matching CSS

You have to monitor the scroll position of the window as the user scrolls through the page.

Here is a basic explanation:

$(window).scroll(function() {
    //This gives the scroll position
    var scrollTop = $(window).scrollTop();
    if(scrollTop >= 1000) {
         //If user has scrolled about 1000 px below then

         // .... Your code to bring the links from left to right
    } 
});
April 15, 2012

PHP header not working for server bu works perfectly fine on local host

Question by user1334969

this below code works perfectly fine when i try on my local host but when i upload it on to my server it dose not work

$sendquery = "INSERT INTO `message` (`from`, `to`, `subject`, `date`,`message`) VALUES ('".$_SESSION['UID']."', '".$toarray['Uid']."', '$subject','$d', '$message')";
$sendresult = mysql_query($sendquery);

if($sendresult)
{
    header('Location: home.php?action=inbox&success=1');

}
else
{
    header("Location: home.php?action=inbox&success=2");
}

is it problem with my server or the code

Answer by Starx

The localhost and webserver have many differences together. I am guessing the problem to be developed on windows and hosted on linux.

Lowercase all the header string and stop the execution after it

header("location: home.php?action=inbox&success=2");
exit();
April 7, 2012

PHP mail() function goes to junk @ Outlook

Question by Robinjoeh

When using the PHP mail() function, the email goes to the junk folder when I use the word “utvecklat” somewhere in my message. (it doesn’t matter where)

But when I’m sending an email from Outlook to another Outlook-account (within the same mail server) it goes to the inbox.

Therefore, I think the problem is related to the mail headers.

I’m using this PHP code:

$subject='=?UTF-8?B?'.base64_encode($subject).'?=';
$emailTo="{$toEmail}";

$boundary = md5(date('U'));

$headers = "MIME-Version: 1.0rn";
$headers .= "Content-Type: multipart/alternative;boundary={$boundary}rn";
$headers .= "From: "{$fromName}" <{$fromEmail}>rn";

$message = "This is a MIME encoded message."; 

$message .= "rnrn--" . $boundary . "rn";
$message .= "Content-type: text/html;charset=utf-8rnrn";
$message .= $message_tmp;

$message .= "rnrn--" . $boundary . "--";

mail($emailTo, $subject, $message, $headers, "-f {$fromEmail}");

The email should be in HTML format. It doesn’t matter if I use “utvecklat“, the email will go to the junk folder anyway.

So, what should I do to avoid the spam filter in Outlook? (must be something to do with my email headers, because mail from Outlook to Outlook within the same mailserver goes to the inbox.)

Thank you!

UPDATE!

Here you have a email sent from a outlook account to another. Can someone “convert” all this headers to a correct PHP mail() code? Thanks!

Return-Path: <example@domain.com>
Delivered-To: robin@example.com
Received: from localhost (localhost [127.0.0.1])
    by example.example.com (Postfix) with ESMTP id 9C67EC21B12
    for <robin@example.com>; Sat,  7 Apr 2012 17:58:14 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at example.example.com
X-Spam-Flag: NO
X-Spam-Score: -2.47
X-Spam-Level: 
X-Spam-Status: No, score=-2.47 required=6.31 tests=[ALL_TRUSTED=-1,
    BAYES_00=-1.9, HTML_MESSAGE=0.001, MIME_HTML_MOSTLY=0.428,
    TVD_SPACE_RATIO=0.001] autolearn=ham
Received: from example.example.com ([000.000.000.00])
    by localhost (example.example.com [127.0.0.1]) (amavisd-new, port 10024)
    with ESMTP id HIlqLaU+2IIL for <robin@example.com>;
    Sat,  7 Apr 2012 17:58:11 +0200 (CEST)
Received: from Ciccidator (00-000-00-000-no56.tbcn.telia.com [00.00.00.000])
    by example.example.com (Postfix) with ESMTPA id 866F2C2059C
    for <robin@example.com>; Sat,  7 Apr 2012 17:58:11 +0200 (CEST)
From: "Example Sender" <example@domain.com>
To: <robin@example.com>
Subject: utvecklat
Date: Sat, 7 Apr 2012 17:58:01 +0200
Message-ID: <000001cd14d7$35d38070$a17a8150$@example.com>
MIME-Version: 1.0
Content-Type: multipart/alternative;
    boundary="----=_NextPart_000_0001_01CD14E7.F95C9E90"
X-Mailer: Microsoft Outlook 14.0
Thread-Index: Ac0U1zWPte9QsazETMuTKG6LDnf1fg==
Content-Language: sv

Answer by Starx

Omitting the junk mail covers a lot of ground, and can never be a 100% solution. Because email filtration might be different from one span engine to other.

  • One the best way to confirm you always receive the mail is to the add the sender’s email address on the recipient’s address book.

  • Another, you should confirm if the sender’s email is not blacklisted on the internet.

  • Always confirm you have sent the emails with correct header.

  • Use Email Libraries like PHP Mailer

Fruther more: Check out this answer about MX entries.

March 30, 2012

My <body> isn't accepting background color/image

Question by langel

CSS code

body { 
    background-attachment: scroll;
    background-clip: border-box;
    background-color: #ececec;
    background-image: none;
    background-origin: padding-box;

}

Link: http://grupocoral.netai.net/

No matter what I do I can’t change background properties.

Answer by Engineer

Remove <style type="text/css"> and </style> from your css file.

Answer by Starx

You have placed your CSS code in the style sheet along with the <style> tags. You shouldn’t do that when attaching an external CSS stylesheet. You can directly define the styles.

Remove

<style type="text/css"> & </style> from your file style.css

March 24, 2012

PHP Excel Header

Question by user794624

header("Content-Type:   application/vnd.ms-excel; charset=utf-8");
header("Content-type:   application/x-msexcel; charset=utf-8");
header("Content-Disposition: attachment; filename=abc.xsl"); 
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
echo "Some Text"

Here is code to write and download xsl file using php,
my problem is when i open excel file MS-Excel show warning before opening file says

The file you are trying to open is in different format than specified by the file extension…Blah blah

What’s to do with PHP code to remove this warning. Contents are written correctly.

i know this is because content written in file are txt file content and file extension is incorrect, that is, xls. Solution???

Please don’t suggest to use any library.

Answer by Starx

You are giving multiple Content-Type headers. application/vnd.ms-excel is enough.

And there are couple of syntax error too. To statement termination with ; on the echo statement and wrong filename extension.

header("Content-Type:   application/vnd.ms-excel; charset=utf-8");
header("Content-Disposition: attachment; filename=abc.xls");  //File name extension was wrong
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
echo "Some Text"; //no ending ; here
...

Please fill the form - I will response as fast as I can!