Let $\{I_n:n\in\mathbb N\}$ be the set of all open intervals with rational endpoints. Construct pairwise disjoint sets $A_n$ $(n\in\mathbb N)$ such that each $A_n$ is homeomorphic to the Cantor set and $A_n\subseteq I_n$. For each $n\in\mathbb N$ define a continuous surjection $f_n:A_n\to[-n,n]$. Define $f:\mathbb R\to\mathbb R$ so that $f(x)=f_n(x)$ if $x\in A_n$ and $f(x)=x$ if $x\notin\bigcup_{n\in\mathbb N}A_n$. It's easy to see that $f$ is Borel measurable and maps every interval onto $\mathbb R$.
P.S. As Martin Sleziak pointed out in a comment the functions $f_n$ can be chosen to be at most two-to one, in which case $f^{-1}(x)$ will be a countable dense set for each $x\in\mathbb R$.